Set up Custom Dimensions using GA, GTM, and the Data Layer

Comments:9

  1. I followed your guide to set-up a pages topic – with the topic itself being auto-generated in the datalayer based upon the category selected when creating the WordPress page/post.

    However when I view the secondary dimension within Google Analytics the homepage (and other pages) seems to be picking up sessions against multiple topics which is incorrect as core can only be selected for it (and is confirmed in the HTML).

    Any idea what’s going on?

    Thanks,

    Sam

    1. Hi Sam, is your dimension in GA set to hit-scoped? Session and user-scoped dimensions will take on the final value in a session so could lead to some unexpected results. If that’s not the issue and you’d like me to take a closer look, please email me your URL, a screenshot of your tag setup, and your custom dimension page in GA.

    1. You don’t need a data layer at all for custom dimensions, it’s an optional but (usually) recommended step. If you don’t have or don’t want to use a data layer, you can instead capture values by scraping them off the page. For example, say you want to pass in a custom dimension for login status. You might find that you can identify whether a user is logged in or out by checking the navigation bar, as they have different menu options (For example, the ‘logged out’ menu has an option to sign in, while the ‘logged in’ menu has an option to check your account). In that case you would alter the above steps as follows:
      1) skip step 1 entirely
      2) complete step 2 as written
      3) instead of setting up a Data Layer variable, set up a Custom Javascript variable, and write a function that returns ‘logged in’ or ‘logged out’ based on which version of the menu bar is visible (or whatever other way you’ve found to identify login status).
      4) complete step 4 as written
      5) since you no longer have a data layer event, you’ll need to instead use the built-in triggers like DOM Ready or Window Loaded to make sure your new JS Variable is resolved and available at the time you send it over to GA.

Leave a Reply to https://chatfilipina.com Cancel reply

Your email address will not be published.