chain_id我正在尝试使用 gtag方法为 GA4 设置一个自定义维度set。我还在custom_map配置中添加了一个属性,但我什至不确定这是否有必要。问题是,chain_id正如您在 GA 调试器的控制台输出中看到的那样,它永远不会与事件一起发送。
不太确定我在这里缺少什么,但我认为chain_id的值Test chain id应该出现在事件参数中。
document.getElementById("another").addEventListener("click", function(event) {
gtag("event", "Button click");
});Run Code Online (Sandbox Code Playgroud)
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<my-ga-id>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("set", {
chain_id: "Test chain id"
});
gtag("config", "<my-ga-id>", {
debug_mode: true,
custom_map: {
dimension1: 'chain_id'
}
});
</script>
<button id="another">Another click</button>Run Code Online (Sandbox Code Playgroud)
javascript google-analytics custom-dimensions google-analytics-4
我正在尝试使用“set”命令将数据添加到通过 javascript 在 GA4 中发送的每个事件:
https://developers.google.com/tag-platform/gtagjs/reference#set
从这些文档来看,它似乎与 Serilog Enrichment 类似,但它似乎不起作用,而且我没有看到这些数据。
我正在使用 localhost + Google Analytics Debugger chrome 扩展。然后,在“分析”>“配置”>“调试视图”中,我看到自定义事件“hello-world”和属性“test”,但没有看到通过“set”命令添加的数据。
我使用 set 命令进行了 2 次调用 - 第一个是有效的“user_id”属性。这一定是一个特殊情况,因为 GA 的处理方式有所不同。第二个是针对不起作用的自定义对象。
控制台显示两个 set 命令调用的一些输出,但没有告诉我某件事已成功或失败
<!DOCTYPE html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-SOMECODE"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
window.dataLayer.push(arguments);
}
gtag('js', new Date());
// Set enrichment properties for every event "on this page"
// https://developers.google.com/tag-platform/gtagjs/reference#set
gtag('set', {
'foo': 'bar',
});
// Set …Run Code Online (Sandbox Code Playgroud)javascript ×1