2

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?

1 Answer 1

1

Create a flat table custom report with page and the applicable custom dimension and then the chosen metrics eg unique event.

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

To pass the custom dimension with the pageview itself rather than with an event, then the tracking code for the relevant pages would need to be adjusted 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>
9
  • Thanks for the response, this has been doing my head in all day! Problem is it only reports correctly when using sessions as the metric -- when using page views I get nothing. See: prntscr.com/p5s88u I'm guessing gtag is attaching the custom dimension to the session and not the page view. Most of the info online I've found is for universal analytics (ga.js) -- is this even possible with gtag.js? Sep 13, 2019 at 17:41
  • Sorry.. edited my reply.. custom report with page and cust dim as dimensions and pageviews etc as metrics
    – Bronwyn V
    Sep 13, 2019 at 17:47
  • Thanks for the quick reply! I'm still getting the same issue: prntscr.com/p5sby2. I think the issue lies with how I'm sending the custom dimension to analytics. Should the custom dimension be sent along with a page view? That's what seemed to be happening with ga.js examples, but I couldn't find out how to do it with gtag.js. Thanks again. Sep 13, 2019 at 17:50
  • I see what you mean.. is being sent with an event. Add the event as a report dimension as well.. you can then apply a filter to the report, to filter within the report table just include that event via category or action.
    – Bronwyn V
    Sep 13, 2019 at 17:58
  • Sorry to be such a bother, I still get the exact same issue -- when filtering with the event action (instead of custom dimension), the report looks exactly the same as prntscr.com/p5sby2. Session reporting fine, but pageviews = 0. Sep 13, 2019 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.