I'm trying to set up a custom dimension for GA4 called chain_id
using the gtag set
method. I've also added a custom_map
property in the config but I'm not even sure if that is necessary. The issue is that the chain_id
is never being sent with the event as you can see in the console output from the GA debugger.
Not really sure what I'm missing here but I think that chain_id
with the value of Test chain id
should be present in event parameters.
document.getElementById("another").addEventListener("click", function(event) {
gtag("event", "Button click");
});
<!-- 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>