javascript - 设置 Google Analytics 自定义维度值而不发送额外的综合浏览量

标签 javascript google-analytics

我需要发送包含从 API 获取的数据的 GA 自定义维度。因此,自定义维度数据将在发送“综合浏览量”后设置。所以默认代码是:

ga('create', 'UA-XXXX-Y', 'auto');

// Set value for custom dimension at index 1.

ga('set', 'dimension1', 'Level 1');

// Send the custom dimension value with a pageview hit.
ga('send', 'pageview');

但在我的情况下,我需要完成以下内容:

ga('create', 'UA-XXXX-Y', 'auto');

// Send the custom dimension value with a pageview hit.
ga('send', 'pageview');

// Load and set value for custom dimension at index 1 from an API
ga('set', 'dimension1', 'Level 1');

---> Send the dimension to Google without double counting the pages in GA

我知道我可以按照第一个示例中的要求设置代码,但我不想在发送“页面 View ”之前等待 API 数据加载。所以我正在寻找一种解决方案来强制输入维度数据。

编辑/更新1:“维度”需要显示在GA中标准综合浏览量的报告 View 中。

最佳答案

您可以尝试将其与另一次点击一起发送,例如非交互事件:

ga('send', 'event', 'custom dimension', 'set', {nonInteraction: true});

但无论如何,它必须被点击发送。

Custom dimension or metric data may only be sent with an existing hit.

(参见Custom Dimensions and Metrics)

关于javascript - 设置 Google Analytics 自定义维度值而不发送额外的综合浏览量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41727554/

相关文章:

javascript - JS : parse time to pull out hours and minutes using date-fns, 忽略时区

javascript - 检索文档下的所有子集合

javascript - HTML 使用带有 onkeydown 的键盘快捷键播放音频

regex - Google Analytics 本地 IP 过滤器不起作用

javascript - 触发.io — 谷歌分析

.NET XML 反序列化的 JavaScript 等效项

javascript - 使用 HTTP-Basic 身份验证的 Angular 6 HTTP Get 请求

google-analytics - 从分析中过滤掉旧的垃圾邮件 URI

google-analytics - 禁止网址显示在Google Analytics(分析)中

google-analytics - 移动 Google Analytics(分析)虚拟屏幕 View