问题
In 2018, I created four custom dimensions for my GA property. They have been correctly collected and are available through the relevant GA reports.
Last week, I added an extra custom dimension, but this custom dimension is not being recorded. I fail to see why.
First, I added the custom dimension under "Custom Definitions" -> "Custom Dimensions", for the property in question.
Then, I map the name of the custom dimension to something more readable, in the header of each page that's recording pageviews through GA.
gtag('config', 'UA-XXXXXXXX-X', {
'custom_map': {
...
'dimension5': 'primaryCategory'
}
});
Finally, I assign values to the custom dimensions.
gtag('event', 'add_dimensions', {
...
'primaryCategory' : '<?php print $primaryCategory; ?>'
});
But, in no report is this new custom dimension available.
What am I doing wrong?
回答1:
Since you're passing your custom dimension value with an event tag it won't appear in Pageview report.
In order to have it reported within page path, you may pass it withing the config
command. You'll need to define your custom_map
before with a set command:
gtag('set', {
'custom_map': {
...
'dimension5': 'primaryCategory'
}
});
gtag('config', 'UA-XXXXXXXX-X', { 'primaryCategory' : '<?php print $primaryCategory; ?>' });
In that case, dimension5
will be passed within pageview
event and properly reported.
Here's a working sample and you could see custom dimension value passed within Tag Assistant.
Also consider reviewing the scope of your custom dimension. While having it as user
dimension you'll only be able to report the last value within the user session.
来源:https://stackoverflow.com/questions/59935092/google-analytics-not-recording-custom-dimension