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