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).
The case (after some testing) is after a user has had a page view that sets the custom dimension, all subsequent page views are tagged with that dimension. We want the custom dimension to only be for the page view that the custom dimension is set on.
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:
- How do I report custom dimensions for page views, not for multiple page views?
If that's not possible:
- 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?
EDIT: Did some more testing, seems that it's actually due to the segment I'm using to report: Under Advanced > Conditions, I'm filtering sessions that include the dimension. So the custom dimension isn't actually applying to all subsequent page views, but rather I've misunderstood the reporting. That said, there's no option for page views. Is there any way to create a segment with filtering for page views that contain the custom dimension, rather than sessions?