0
votes

The case: We are running a test on 5% of page views (NOT USERS) with a different ad layout. We are looking to tag each page view that has the different ad layout with a custom dimension.

The custom dimension scope is "Hit".

The problem we're running into: Google Analytics reporting is showing more than 5% of page views with the custom dimension. We know (via other reporting) that the different ad layout is only being shown to 5% of traffic (so Google Analytics is overreporting).

I'm assuming this is happening because the dimension we're setting is staying for subsequent page views (i.e. once a user has been tagged with that dimension, all page views after that are tagged). This is almost certainly due to a misunderstanding of how dimensions work and/or the code.

The code:

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID', {
    'custom_map': {'dimension1': 'adlayout'}
});

Later on in code:

gtag('event', 'adlayout_dimension', {'adlayout': 'true'});

Questions:

  • Are custom dimensions the correct way to do this? Is there a better feature for tagging a page view in Google Analytics?
  • If so, where am I going wrong with my code/setup that's causing it to overreport?
2

2 Answers

2
votes

The event is firing after the pageview and the custom dimension is associated with the event.. not the pageview.

To fix it going forward, pass the custom dimension with the pageview itself rather than an event. To do so, edit the tracking code for the relevant pages similar to the following

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'GA_TRACKING_ID',{
  "dimension1": "true"
});
</script>

You can then create a custom report using a flat table, with Page and the Custom Dimension as dimensions together with the desired metrics.

0
votes

I think that in this case the most suitable scope is at session level. In this way you can see all the sessions that have seen a particular page tagged (obviously if in a session you can see more than one page tagged with your system only the last value will be saved).

Otherwise at hit level but only for specific pages and looking at unique pageviews.