Google Analytics not recording custom dimension

﹥>﹥吖頭↗ 提交于 2021-01-29 10:15:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!