# 如何连接 Google Analytics

## 这个功能是做什么的

在使用我们的产品前，你需要先让网站数据可被读取。\
整个过程分为两步：

* 第一步：让 Google Analytics 4 采集你的网站数据
* 第二步：将 GA4 连接到我们的平台

***

## 为你的网站接入 Google Analytics 4

***

### 如果你没有 Google Analytics 4账户

#### Step 1：创建 Google Analytics 4 账户

**1.1 开始设置**

* 打开 [Google Analytics](https://analytics.google.com/analytics/web/provision/#/provision)
* 点击 **Start measuring（开始衡量）**

<figure><img src="/files/fBa4zcwdCAnzTrv6On42" alt=""><figcaption></figcaption></figure>

**1.2 创建账号**

* 输入 **Account name（账号名称）**

<figure><img src="/files/upjmdj1Wpu11KcEw5Svt" alt=""><figcaption></figcaption></figure>

**1.3 创建媒体资源名称（你的网址名称）**

* 填写网站名称
* 选择时区（Australia/Sydney）
* 选择币种
* 选择行业类别和业务目标

<figure><img src="/files/bBKjnDGH5XK6GAsnJFGW" alt=""><figcaption></figcaption></figure>

***

#### Step 2：创建数据流

**2.1 选择平台**

* 选择网站

<figure><img src="/files/P0KW0DbBAm9ta5EGnk0E" alt=""><figcaption></figcaption></figure>

**2.2 填写信息**

* 输入网站 URL
* 设置数据流名称
* 点击创建并继续

<figure><img src="/files/X4YZu3pIvLvypA7RChsc" alt=""><figcaption></figcaption></figure>

**2.3 获取 Measurement ID**

* 复制生成的 **G-XXXXXXXXXX**

***

#### Step 3：安装 GA4

**方式 A：手动安装（适用于自建站或者熟悉代码的用户）**

<figure><img src="/files/bVTBikVOgL2vkYCyQqPm" alt=""><figcaption></figcaption></figure>

1. **复制代码**

* 点击 **View tag instructions（查看标签说明）**
* 复制 **Global Site Tag（gtag.js）**

2. **添加到网站**

* 将该代码复制并粘贴到您网站上**每个网页**的代码中，紧跟在 `<head>` 元素之后。
* 确保应用于所有页面

3. **发布**

* 保存并发布网站

***

**方式 B：通过 Measure ID安装（适用于不熟悉代码的用户）**

1. **进入 GA4 后台**

* 打开 Google Analytics
* 登录你的账号
* 进入你刚创建的网址追踪页&#x9762;**（媒体资源）**

**2. 打开管理页面**

* 点击左下角 **Admin（管理）**（齿轮图标）

<figure><img src="/files/Ein3F57Nf39DwEjj9bEN" alt=""><figcaption></figcaption></figure>

**3. 进入数据流（Data Streams）**

<figure><img src="/files/0JD9I7epC0ovyIQSUSiE" alt=""><figcaption></figcaption></figure>

* 在中间一列（Property）找到： **Data Streams（数据流）**
* 点击进入

4. **选择你的网站**

* 你会看到一个 **Web 数据流**（你刚刚创建的）
* 点击进去

5. **找到 Measurement ID**

👉 页面右上角会看到：

```
Measurement ID: G-XXXXXXXXXX
```

6. **复制**

* 复制这个 ID
* 后面在 Shopify / WordPress / Wix / 代码里用

<figure><img src="/files/G0OCnhoTBlzMYezK8zTR" alt=""><figcaption></figcaption></figure>

7. **复制粘贴到到网站里**

**Shopify**

* Settings → Customer events / Google channel
* 粘贴 Measurement ID

**WordPress**

* 安装插件（推荐 Site Kit）
* 登录 Google Analytics 4
* 自动连接

**Wix**

* Settings → Marketing Integrations
* 粘贴 Measurement ID

***

#### Step 4：验证

**4.1 打开实时数据**

* 进入 GA4 → **Realtime（实时）**

**4.2 测试访问**

* 打开你的网站

**4.3 确认**

* 如果看到访问数据 → 说明GA4已经成功连接你的网站并开始记录数据

***

### 将 GA4 连接到我们的平台<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.workfx.ai/chan-pin-shi-yong-zhi-nan-zhong-wen/get-started/publish-your-docs-1/ru-he-lian-jie-google-analytics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
