Comments on: Set up Custom Dimensions using GA, GTM, and the Data Layer https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/ APIs, Sheets, and Analytics Thu, 23 Feb 2023 05:35:55 +0000 hourly 1 https://wordpress.org/?v=6.5.5 By: Ana https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-22307 Tue, 02 Feb 2021 07:02:07 +0000 http://mixedanalytics.com/blog/?p=1690#comment-22307 In reply to cri.

Yes, that sounds right to me! : )

]]>
By: cri https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-22296 Mon, 01 Feb 2021 18:51:31 +0000 http://mixedanalytics.com/blog/?p=1690#comment-22296 Hello Ana, thank you for your amazing guide!

I already have a tracking tag on the site (not implemented with GTM). So I set the tracking type from Page View to Event (to avoid track twice) and no interaction hit to "true". Did I do it right? I'm setting up custom dimensions to create remarketing audiences

]]>
By: Ana https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-22178 Wed, 27 Jan 2021 12:09:03 +0000 http://mixedanalytics.com/blog/?p=1690#comment-22178 In reply to Jon.

I see, I'm glad you resolved it. Thanks for the update!

]]>
By: Jon https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-22176 Wed, 27 Jan 2021 11:12:26 +0000 http://mixedanalytics.com/blog/?p=1690#comment-22176 In reply to Ana.

Thanks for the pointers. We've fixed this issue by overwriting GA settings and adding the custom dimension to all of our tags, in stead of just the GA tag.

]]>
By: Ana https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-22154 Tue, 26 Jan 2021 15:27:28 +0000 http://mixedanalytics.com/blog/?p=1690#comment-22154 In reply to Jon.

It sounds like you may have a race condition, where the variable isn't reliably populated in time. This can happen if your variable is being done through a custom JS variable instead of being pushed in via the data layer, or if it's not getting populated until the second page view.

Another possibility is there's an error in the code, that is less likely though.

Can you do some investigating to find common threads among the 15% that isn't set? For example, are they on mobile, are they single-page visits, any specific browser? And can you make sure your logged in status is being pushed in through the data layer rather than through scraping the status into a custom JS var?

]]>
By: Jon https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-22148 Tue, 26 Jan 2021 11:37:51 +0000 http://mixedanalytics.com/blog/?p=1690#comment-22148 Hi,

After adding a custom dimension for login status we're seeing the proper results in Analytics. The only issue we have is that with maybe 15% of our visitors the custom dimension is simply not set. Which is strange, because we set the dimension with every pageview. The only hint we have is that all of these users also trigger other kinds of events, for example when they hover over our menu, or submit a form. What could be causing this?

Jon

]]>
By: Ana https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-21430 Mon, 21 Dec 2020 06:02:31 +0000 http://mixedanalytics.com/blog/?p=1690#comment-21430 In reply to Luca.

Hey Luca, what you're talking about is called DOM scraping. GTM has some built-in listeners for this, for example Click Text, if you want to track what someone clicked on. If you want to track elements of the page like titles and headers, you usually need to create custom JS variables that pull in the text you're looking for. You need to have some basic JS knowledge to do this, or if you know about CSS selectors you can modify this simple example script and include it in a custom JS var:
function (){
var entryTitle = document.querySelector(".entry-title").innerText;
return entryTitle;
}

You can see some more example scripts here: https://mixedanalytics.com/blog/useful-custom-js-variables-google-tag-manager/. Once you have your custom JS variable, you attach it to the custom dimension field in a page view or event tag, just like you would any other dimension.

Hope that helps point you in the right direction.

]]>
By: Luca https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-21421 Sun, 20 Dec 2020 20:40:16 +0000 http://mixedanalytics.com/blog/?p=1690#comment-21421 fantastic explanation! How can I scrape text from my pages to show in GA? For example, title tags, Header 1 and 2, title length by adding secondary dimensions? I know it's possible but I am not sure how exactly.

]]>
By: Ana https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-20972 Fri, 04 Dec 2020 10:39:45 +0000 http://mixedanalytics.com/blog/?p=1690#comment-20972 In reply to Jason.

Hey Jason! It would need to be a custom event that fires on every page. That’s why my GTM event name is “pageview”, it’s an event that fires on every page view. You would set this event key at the same time you’re pushing your custom dimensions into the data layer.

In your case, where you’re pushing a data layer only on certain pages, this approach won’t work. Can you push your data layer key on every page, and just leave the values as null for those content types you don’t want to populate? If not, you’ll have to use the native All Pages trigger, and double check that your data layer values are ready when that All Pages trigger fires.

]]>
By: Jason https://mixedanalytics.com/blog/ga-gtm-datalayer-custom-dimensions/#comment-20922 Wed, 02 Dec 2020 15:41:15 +0000 http://mixedanalytics.com/blog/?p=1690#comment-20922 Hi Ana,

Very clear article! However, one thing I don't really understand:
In step 5 you add a trigger to the GA Page view tag. Normally I would use the All pages trigger, but you advise not to use this. So I tried your option with the custom event trigger. But now the GA tag only gets triggered when there is actually a custom event on the page. But this is not always the case. If a dataLayer is only filled with that custom event on certain pages (certain content in my case), then on other pages the GA tag is not triggered anymore and GA does not track anything.

What am I missing here?

Thanks for your reply!
Jason

]]>