如何从Odoo仪表中跟踪你的网站流量

警告

It is not possible anymore for new Google Analytics accounts to integrate their Google Analytics Dashboard inside their Odoo Dashboard. Google deprecated Universal Analytics which won’t be supported anymore in July 2023. They are replacing it with Analytics 4. New accounts are already using it.

Analytics 4 doesn’t allow its dashboard to be integrated in external websites.

You now have to check your Analytics data directly in the Google Platform as it won’t be possible in Odoo anymore.

Accounts created before October 2020 should still be using Universal Analytics and be able to integrate their dashboard on external website until the official end of support around mid 2023.

有了Google Analytics,你可以直接从Odoo网站跟踪你的流量统计。

  • 准备步骤包括创建一个Google Analytics账号并在网址设置中输入跟踪ID(参见doc:google_analytics

  • `Google API平台 <https://console.developers.google.com>`__中生成Analytics API 凭证,再用Google账户登录。

  • 选择Analytics API。

../../../../_images/google_analytics_api.png
  • 创建一个新项目并命名(如Odoo),此项目用于存放你的API凭证。

../../../../_images/google_analytics_create_project.png
  • 启用API接口。

../../../../_images/google_analytics_enable.png
  • 创建一个用于Odoo的凭证。

../../../../_images/google_analytics_create_credentials.png
  • 选择 网页浏览器(Javascript) 作为调用源,选择 用户数据 作为数据类型。

../../../../_images/google_analytics_get_credentials.png
  • 接着创建一个客户端ID。输入应用的名称(如Odoo)及允许转向的页面。授权JavaScript源文件 是你的实例URL地址,授权转向URI 是你Odoo实例的URL地址’/google_account/authentication’。

../../../../_images/google_analytics_authorization.png
  • 输入产品名称(如在Odoo中输入Google Analytics),完成用户许可步骤,可任意选择自定义选项(非强制)。只有第一次在Odoo中输入客户端ID时显示用户许可画面。

  • 最后,你会获得一个客户端ID。将此ID复制粘贴到Odoo。

../../../../_images/google_analytics_client_id.png
  • 在Odoo中打开你的网站仪表板,并将你的分析帐户链接到过去的客户ID。

../../../../_images/google_analytics_start.png
  • 最后,授权Odoo访问Google API接口。

../../../../_images/google_analytics_login.png