Track custom events on GA inserted by GTM - google-analytics

I have inserted Google Analytics using Google Tag Manager on my site.
Often, an site has only one analytics. But when you have multiple, analytics recommends to name them.
Custom Events using ga("send", "...") only apply to the global analytics instance. I need to track an Ajax Form with custom events. If you have a named instance, you need to call ga("INSTANCE_NAME.send", "...").
The problem: Tag Manager is inserting the analytics with an name (gtm1) even having only one instance. This way, i need always to set the name on custom events and on my case, i can't do it because i use an plugin.
What i need is to remove the name inserted by tag manager and use an global instance, but i want to keep using the tag manager to insert the tag.

In the advanced settings there is a field where you can override the tracker name (if you use a settings variable you need to check "enable override settings" first). I haven't done this for some time, but it used to be that if you enabled the field but did not enter a name the tracker name would revert to the default.

Related

Track external search form in Google Analytics/GTM

We have a search box on our website that searches a product we subscribe to. It's hosted on the third party's server, not on our domain.
Since it's just embedded on our site, I can't use Google Analtyics' built in configuration for tracking site search.
Is there another way I can track the terms used to search in the form, using either Google Analytics/Tag Manager?
yes, you can use GTM if the search query is entered on your site. Let's say, using a trigger on the search CTA click, you can then use a custom JS variable where you get the value of the search field using JS, use that variable in a GA event tag and there you have your value logged in GA.

How can I rewrite a URL in Google analytics/Tag Manager

I have a website with a URL of mysite.co.uk and a webform being developed by an agency that will have a URL of subdomain.mysite.co.uk
Both will use the same tag manager container and google analytics.
However, in analytics page views to subdomain.mysite.co.uk appear as "/" which clashes with the homepage for my site. How do I tell analytics or tag manager that this a different path e.g "/webform"
I presume you are using Universal Analytics (not the new GA4, altough his has a similar mechanism).
In the GA tag that tracks your form, go to the "more settings / fields to set" section. Here you can overwrite the default data (if you use a GA settings variable, you need to check the "Enable overriding settings" option first).
In the field reference you can look up which field you need to overwrite. You want to set a custom document path, and the relevant field name for that is "path".
So, set the field name to "path" and the value to a value of your choice, hit preview or publish, and see if you like the result.

Implementing User-ID With Google Tag Manager

I have added Google Tag Manager to our site, and using the data layer inserted several custom dimensions, including 'user_id'
Data Layer with user_id shown
The Google Analytics variable in Tag Manager is configured to pass these data layer variables into the coresponding dimensions:
Tag Manager Variable & Dimensions in Analytics
I know this is working as I am able to add this as a secondary dimension in Analytics when viewing reports:
Analytics with Dimension Shown
However, the user view that is created when I have set up the User-Id isnt showing anything:
Creating the User View
We installed Tag Manager using the recommended steps:
Installation of Tag Manager
Do we also need to add the 'Global Site Tag Tracking Code'?
How to Implement the User-ID in your tracking code
If not, what am I doing wrong?
You're actually REALLY close. You actually don't need to create the custom dimension.
The correct way is to set the userId field in your GA tag (I did it through a GA variable so it is applied everywhere).
Yes, that is exactly correct (what #XTOTHEL answered above), but for those who are reading this, I found these two blog posts helpful (esp if you are using GTM):
GA UA: https://www.analyticsmania.com/post/google-analytics-user-id-with-google-tag-manager/
GA4: https://www.analyticsmania.com/post/google-analytics-4-user-id/
And of course, the GA docs: https://support.google.com/tagmanager/answer/4565987?hl=en

Need to Implement Custom Dimensions through Google Tag Manager

I have created virtual pageview tag successfully for " New Registrations" via Google Tag manager.
Now, I want to add two custom dimensions using same Tag i.e. Customer ID and UserRole.
Actually, I am not sure where to add the code to get dynamic values for CustomerID and UserRole. Can you guide me to complete this?
Custom dimensions are configured either in the Google Analytics settings variable (if you use this), or in the tag via the "More Settings" >> "Custom Dimensions" settings or both.
If you use a settings variable and want to add extra dimensions to a specific tag you need to tick the "Enable override settings" checkbox.
In the settings you enter in the first field the numeric index of the dimensions (you can look this up in the property settings of your GA account where you have created the dimensions), the second field takes the variable with a value (or a simple string if it's not a dynamic value).

Google tag manager Track page by content

I created a google analytics account for my website and created google tag manager account too. And both of the accounts are linked and working well.
I have a new requirement which is , my client wants users to allow chance to edit there webpage and create custom templates.
Scenario is ,
User log in to the system
Go to genaral page
Use genaral page or edit genaral page and create custom template for it
Next time user log in to the system and go to the genaral page , User created Custom template appear as genaral page, But same URL
If you can get the point , Same URL but the content is different ,
I applied google tag manager to track those pages, Because of having same URL its tracking as a same url,
But I want to track the page by content and track user if user used my genaral template or custom template.
Hope any one will have a idea to how to create Google Tag or Macro or Rule , Or custom java script for it.
Thanks in advance
By far the best way would be to include a dataLayer variable into your templates that indicated which template is being used. Best to include it above the tag manager code:
<body>
<script>
dataLayer = [{
'template': 'default',
}];
</script>
<!-- Google Tag Manager -->
...
<!-- End Google Tag Manager -->
so it's immediatly available when the GTM code loads. Then create a dataLayer variable in GTM that reads the value for the "template" key from the dataLayer and pass it as a hit based custom dimension to Google Analytics (i.e. in the property settings in GA under "custom definitions" you create a new custom dimension and set the scope to "hit"; in GTM you go to "more settings/custom dimensions", add the numeric index of the dimension you have just created and pass your new dataLayer variable as dimension value). Then you can segment your page hits in Google Analytics based on template type.
I'm sure it would be also possible to track by content (i.e. you could load the content into a js string variable, create a hash value from the string and send that as a custom dimension), but that would mean even fixing typos would result in a new id. Using a variable per template seems much more prudent.
If supposedly your different templates have some ID's in the code - you can use this ID as identifier for the template and create variable to check if the ID is present, then fire it in GA, in similar way as the Eike's description.
But this is the sloppy way, and it's an option if you have no way to create dataLayer push for the new templates, as described by Eike. Otherwise the dataLayer push is the better way to do the job.

Resources