This event and all onclick events like it are not tracking in Google Analytics Real Time. Any idea why not?
email#domain.com
This is not specific to mailto links. This is for any link where I'm trying to use onclick event tracking.
In case you're wondering I do not have an IP filter set.
We're using gatag.js (newer version of ga.js). I was still using the syntax from ga.js The syntax for tracking an event is slightly different in the newer gatag.js. That was my issue.
Related
Completely new to GTM and having trouble getting ecommerce conversion tracking to work on GA4. This is what debug mode looks like in GTM the tag doesn't fire. Does anyone know what could be causing the issue?
Have research all the possible reasons, checked the source code, spoken with the developer who added the GTM container to the site, reviewed the tag itself but still none the wiser.
Look at the trigger is waiting for a datalayer event : add_to_cart.
So you need to ask the developer to push a datalayer event with ecommerce item when user successfully perform an add_to_cart event.
Here is the detail about all ecommerce event and its datalayer.
https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm
You have done half of the job. The there is still another part need to be done.
When using the Google Tag Manager, is it possible to track some things the old way in addition to using the GTM?
For example, I use GTM in order to fire a page view.
However, I want to fire another page view, when a user clicks a button, also known as a virtual page view.
The button in question doesn't have an ID and I don't trust the othet agency, which handles these buttons to consistently keep the same IDs for these elements. So I would rather have them be responsible for these types of page views.
The code for the virtual page view would look something like that:
ga('send', {
hitType: 'pageview',
page: 'button2'
});
Since the tracker is already initialized by GTM, I would only have this code outside GTM.
Would this work if all other google analytics related things run over gtm and where should I put this code in this case? Somewhere after the GTM code on the page I'd imagine?
Google Tag Manager (GTM) by default uses a random name for each tracker, generated for each Universal Analytics tag. There is a possibility to use fixed name for trackers, which is highly discouraged. This means, that you might have difficulties to identify the proper tracker to use, when sending your additional pageview data.
There are however other methods to send virtual pageviews using GTM, where you can benefit from your existing Analytics settings, defined in Google Tag Manager. (Preferably by using Google Analyitcs Settings variable.)
As far as I understand, you have control over the code, to run some JavaScript on the relevant click event.
So instead of directly invoking the ga object, you can send the desired data to GTM, with a call like this:
dataLayer.push({
event : 'virtualPageView',
virtualPagePath : 'button2'
});
Obviously, there are a couple of things you need to set up in GTM, which will be able to act on this event, and send the pageview to Google Analytics.
Create a variable that points to virtualPagePath dataLayer variable, so the newly pushed value could be reused
Create a custom event trigger, that can be used with one or more tags. The event name should match your given event name, virtualPageView in my example.
You need an Universal Analytics tag, which will send the pageview. This tag should be fired by your new custom event trigger, and should have an extra setting compared to your regular pageview tag. Namely, page variable within the Fields to set block should point to the newly created dataLayer variable, that contains your virtual page path.
This way, Google Tag Manager will take care of creating the tracker for you, sending the hit to Google Analytics, and using the virtual page path variable provided by you, instead of the URL in the browser address bar.
So, I have an event firing when a mailto link is clicked, which is working fine:
Then I added a goal, with the properties of the event. (I should probably mention this was already in place, I didn't just add it after firing the event). I successfully verify it should work:
...But the conversion goal just isn't getting hit:
Screencast here: https://youtu.be/VClrTtVeizw
Am I doing something wrong? The fact it verifies makes me think not but I'm not a seasoned Analytics user so any advice would be great.
I have created a tag which fires when the click url contains certain words. When I view the website in GTM debug mode the tag is getting fired. But the event is not getting captured on Google Analytics Real Time Events.
The following is the screenshot of my tag and trigger.
Will the real time events in Google Analytics not show until I publish the changes in GTM?
What the possible problems you may have(as you are saying your tag is firing and IP was not filtered in GA:
Your tracking ID for GA is incorrect(or you are checking data in the wrong GA property): your tag config looks correct, so data should be sent to GA(as you are saying GTM trigger works fine);
Trigger name is hidden, but looks like trigger type is "Click". Make sense to check if option "Wait for tags" was enabled. If this option is disabled and after click user redirecting on another website page, GTM may not have enough time after click and before redirection to send data to GA. And your tag will fire, but data will not be received to GA.
I had the same problem. It ended up being a double up in the GA id. I had used a constant variable to define the GA property but not removed the ID itself.
I have google analytics on my site.
One page has a button which when pressed executes some javascript.
It would be nice to monitor the number of hits the button receives when people come to this page.
Can anybody suggest the easiest way to achieve this with google analytics ?
Are there any best practices to do this ?
thanks
You can trackPageview in the link's onclick handler:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55521
<a href="javascript:void(0);"onClick="javascript:pageTracker._trackPageview('/folder/file');" >
This inflates your pageviews though, so it may be better to so use GA event tracking:
http://code.google.com/apis/analytics/docs/tracking/eventTrackerOverview.html
Play
Updated Answer
Here is the new method for Google Analytics event tracking:
<button onClick="ga('send', 'event', 'Category', 'Action', 'Label');" >Button text</button>
Category: Typically the object that was interacted with (e.g.
'Video')
Action: The type of interaction (e.g. 'play')
Label (optional param): Useful for categorizing events (e.g. 'Fall Campaign')
More info here: https://developers.google.com/analytics/devguides/collection/analyticsjs/events
The google analytics snippet sends google the page URL (among other things, probably) every time it's executed. I don't think you will be able to use it to count button clicks. If you execute the same snippet, it will keep sending the page's URL which is hardly valuable. If you manage to change the URL it sends, you might be able to get something...
Update:
You were right and I was wrong: google analytics does in fact support tracking events other than page loads.