How to get virtual pageviews heatmaps in Microsoft Clarity via Google Tag Manager? - google-tag-manager

I am trying to add Clarity for monitoring a wizard funnel which dynamically changes content whenever the user goes through every wizard steps.
I have followed the online docs to have custom identifiers for virtual pageviews, and I have the triggers already tested within Google Tag Manager that launches the code in the below way:
<script>
window.clarity("identify", {{custom_user_id}}, {{custom_session_id}}, "wizard_step_2");
</script>
Even if the code seems working fine, with no errors inside JS console, I do not know how to filter Clarity heatmaps using the pageId value "wizard_step_2"

Related

how to fire google tag manager custom events with data layer

how to add google analytics in my chrome extension, in react js ..
i want to fire some custom event when my specific condition is satisfy and I want to show in google analytics .
please guide me step by step
In order to integrate Google Analytics into your React app, you first have to create the respective GA Property (which I am sure you have already done on the Google Analytics website). Then copy the script that Google Analytics provides and add a script element into the body of your React app that contains the copied script at runtime.
I wrote an article explaining exactly this problem in-depth, you can read it here.

Google Tag Manager / Analytics wrong accounts

I created a new TagManager Account.
I added the Code to the head and body space on my website.
I created a Container.
I added a Google Analytics Tag
I created a Variable with exact the UA-XXXXX-1 id for my property.
(I have dozens of different Google Analytics properties in my account.)
Now when I publish the Google Tag Manager changes, the Tag is published and visible. But it publishes a SECOND WRONG property-ID. UA-XXXXX-2.
Yes, the UA-XXXXX-2 is also in MY ACCOUNT. But a complete different Website property!
I have no clue where the TagManager - which is setup completely new - gets the ID from another property. I didn't provide that ID anywhere (the property is archived).
The "Google Tag Assistant" is telling me that I have multiple Tags implemented, but that could not be true.
Error Message: (Multiple Google Analytics tags detected)
How can I solve that?
Affected site "www global-nights com"
This is not a GTM problem. The second account is bundled in a Javascript file (/cdn cgi/apps/head/6sJWcjIvV53_JPO8tyNGb15vJYg.js) included on the top of your page:
So I guess you should be looking into your Cloudflare settings rather than be looking at GTM.

How to add Adsense in Google Tag Manager

I want to use Google Tag Manager to serve Adsense so I also can use other ads from other sources. I found few answers across the sites but not enough to understand. I would appreciate input here if it is possible to use Adsense code in GTM, if yes how? I also use DFP, if I have to use DFP then how it would be.
I assume you already have Google Tag Manager (GTM) running on your site?
Click on Variables on the left side of the screen within your GTM workspace
Create a new user defined variable and call it asClientID
Configure the variable as a Constant. The value to enter is your AdSense Client ID
Click on Tags on the left side of the screen within your GTM workspace
Create a new Tag called AS - Page view - ALL
Because there is no built-in tag in GTM for AdSense you need to use the Custom HTML tag.
Copy and Paste the HTML code shown below into GTM.
Select the trigger All Page views
Test your changes in preview mode
Once everything is working publish the changes to LIVE.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "{{asClientID}}",
enable_page_level_ads: true
});
</script>
As you can see we are using {{asClientID}} in the script which you have created in step 1 and 2. The reason for creating this variable is flexibility. If you need to change the ID you change it within the variable and not within the code.
NOTE: that it is not best practice to implement AdSense via GTM, but it is possible.
Hopefully this is what you are looking for. Please do let me know if it works for you. :-)

Google Tag Manager - (enhanced) e-commerce - how to load Javascript after <body> tag

I'm still learning Google Tag Manager and Enhanced E-commerce tracking, but I have a few questions, some of which may be pretty basic:
We're using a site on a third party system - I already have Google Tag Manager in my template within the HEAD tag, working with Universal (Google) Analytics. However, we want to just get the e-commerce transaction (purchase) data into Analytics - so basic e-commerce tracking would be fine, but I'd rather use Enhanced E-commerce tracking since it is newer - even though my immediate requirement is just to track purchases.
So, I need to send push transaction data into the dataLayer, but I can't do this due to restrictions on the system. I can only add special Javascript code to the end of the BODY tag for my "checkout complete" page.
Reading this online, the dataLayer must be defined in the HEAD before the GTM code is in place. As I cannot do that, I need to load the data using Javascript at the end of BODY.
Is this possible, if so how? I think I can do this using a Custom Javascript Variable as mentioned here: https://developers.google.com/tag-manager/enhanced-ecommerce#macro
Is a "macro" the same as a "variable" as explained in the above link? It says "macro", but Google Tag Manager allows me to define a custom "variable" which is "Custom Javascript". Just checking that these are one in the same.
Where would this code actually "run", if I put it in Google Tag Manager? The third party system defines some variables for me during script execution and I don't know where/when (during page load of the checkout thank-you page) it does it, so to be safe, I'd rather have this script run at the end of the page before the BODY tag closes - if I were doing this manually using plain Javascript within the HTML. In Tag Manager, how would I tell the Javascript to run "at the end of the page"?
Thanks in advance!
1 - Use dataLayer.push() in your Custom Javascript at the end of the BODY. Include an event in this with the transaction data.
For Example:
dataLayer.push( 'event' : 'custom.transaction', 'ecommerce': {} );
You can see the ecommerce object structure here:
https://developers.google.com/tag-manager/enhanced-ecommerce#purchases
dataLayer.push() is used after Google Tag Manager script has been included on the page, so you won't need to define it in the head of the page. Just translate your available ecommerce data into the structure required.
You then need to set up a Custom Event trigger in Google Tag Manager that uses/matches your event value/name.
Then create a Universal Analytics Event Tag that uses this Trigger. Set what ever you would like for the Category, Action and Label. Under More Settings > E-commerce, check Enable Enhanced Ecommerce and then check Use dataLayer.
This event is simply used to pass the Ecomemrce Data into Google Analytics.
2 - Macro is the same as Variable. You are correct Custom JavaScript Variable is what you are after.
3 - The code lives in Google Tag Manager Variable scope and is executed when the variable is used and/or with Google Tag Manager state changes. You can't make this code run at the end of the page. Also this code would need to access/scrape values from the page. To ensure the data is available you would only use this Variable on a Tag that is set to trigger on Window Loaded / DOM Ready, depending on when the on page data is ready.
I would suggest using dataLayer.push() and only use the Custom Javascript Variable approach if dataLayer.push() is not possible.

Google Analytics not generating data

I'm new to Google Analytics. Yesterday, I created an account and I pointed it to our website. I've added the JavaScript codes that Google Analytics generated for us. I put the code on all of our .html files.
I've been hitting our website from outside and so does my officemates since last night and also today. However, when I visited https://www.google.com/analytics under Reporting, everything was showing 0. I don't see any single spike at all.
I would recommend navigating to the Reporting -> Realtime -> Overview tab within your Google Analytics (GA) account. This is an almost realtime view into users on your site. In a separate tab access your site and refresh the page, this page view event should then be visible in the GA Realtime view.
If you can see your page view then its likely that you've inserted the correct GA script into your page and that you've used the correct GA property id. If you cant see your own page view then you will know that your script is incorrectly inserted or your GA property id is incorrect.
Last bit of advice: GA often has a 24-48 delay before you are able to use its full suite of insight tools (such as GA Goals). If you're expecting to see Goals populate immediately you're gonna have a bad time.
Last-last bit of advice: make sure that you select the current date from the date range picker in the top right of the GA Reporting view. It defaults to yesterday.

Resources