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?