Analytics User-ID view not tracking events - google-analytics

I've created a new view in Google Analytics with everything set up the same as a currently functioning one, only with the addition of User ID tracking turned ON. It's using the same property so the UA code has not changed.
I've copied over everything that I can think of from the current view to the new view. At first glance everything was working fine, page views were coming through via Real-Time correctly and matched up with the values seen in the current view.
For some reason though, the new view is not listing ANY actual events in Real-Time, however the events graph is being populated.
The current view IS tracking all the events correctly.
We use Tag Manager to handle all our events among other things, and using the debug mode, all events were also being triggered correctly. Finally, I've also used the GA Debugger chrome extension, which again is not showing any issues. The new User ID property is being passed through to analytics as I'd expect.
I've tried searching for any issues related to User ID views and tracking events, but came up blank, presumably because there is no inherent issue with this set up.
Any suggestions?

I found out that the reason that the events were not tracking is because the user id was not being sent along with every event.
I believed that once it was set on page load every analytics interaction after that would use that user id. This was not the case. In Tag manager I added a 'Field to set' property for all relevant tags like so;

Related

Firing a trigger group multiple times on a page

I need some help with Google Tag Manager and Google Analytics.
I want to send a pageview to Google Analytics if a user is viewing an image in a gallery on an article. The user is staying on the same URL, when he is viewing an image.
I created a trigger group which consists of two events
• Consent given by the user to use Google Analytics
• Event which is fired when an image in a gallery is being viewed
This works so far so good. Unfortunately, the trigger group is only being fired once on a page. When a user open the gallery and views the image and scrolls to next image, he is staying on the same URL. In that case, the trigger group is only being fired once.
How can I achieve that the trigger group is being fired multiple times on the same page without removing the second trigger (consent)?
I found out that I can create a second trigger group and add two image views and the consent as a trigger. But this solution means that I have to create 100 new tags, which is kind of crazy. Is there any workaround?
Thanks in advance
Once consent has been given by the user in a way that each pageview can pick up (e.g. you're setting it in some persisted state: data layer, cookie, etc.), you're ultimately just looking at triggering when the event happens.
Since you describe a scenario where it happens only once, I'd urge you to take a look at the other triggers on your tag and remove the page-specific trigger your description suggests you have in place. Replace it with only your event and consent triggers and it should work every time an event is observed.

Why GTM server container duplicates intercepted GA4 client events?

I have server-side tracking implemented using Google tag manager.
I noticed duplicate events coming in but not because my GTM web container sends duplicate events (verified in debugger).
The GA4 client in my GTM server container receives two identical event calls, for no obvious reason. The only difference is the param _s:
https://www.google-analytics.com/g/collect?[...]&_s=1
https://www.google-analytics.com/g/collect?[...]&_s=2
I've dealt with this by creating a query parameter variable:
And then excluding all calls where the _s param equals 2 from my GA4 event trigger:
This solves the issue but seems like a hacky solution.
I wonder why two identical server events get triggered in my GTM server container, for a single GTM web event, in the first place?
I had a similar problem, and I couldn't solve it by filtering the parameter because it happened later (I think the params of the two events were _s=6 and _s=7).
I started looking for blog posts until I've found this one: https://www.thyngster.com/google-analytics-4-events-demystified-ga4. The suggestion that helped me was this one:
You may see events being fired on the browser that you didn't define on Google Tag Manager or GTAG. This is normal, don't go crazy with it. If you see a duplicate event or a new event that you don't know where it's coming from take a look at the Data Stream Settings
And, in fact, inside Data Streams was the solution to my problem: under Events settings > Create Events, someone had created a custom event based on the same name as the one I was firing through code, in my case it was add_to_cart.
Disabling the custom event solved the issue.
EDIT
I forgot to mention that the first way of debugging this issue was to check the value of the dataLayer variable in the browser console. This variable keeps track of all the events, together with their send_to attribute. Before looking into the analytics dashboard you should check whether you are sending duplicate events from the code and whether you are firing other events with the same name but without the correct send_to attribute, which will result in two events with the same name firing to the stream you are tracking.

Execute Google Analytics Functions in addition to Google Tag Manager

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.

Google Tag Manager and Single Page apps

I'm trying to integrate Google Tag Manager with my Ember app. I'm having a hard time understanding how to notify GTM that the page changed, and send a page view event.
I've read a lot of things online, mostly working around creating a new variable for a "virtual page" or something, but obviously this is far from ideal.
I'd like to be able to just use dataLayer.push to notify the page actually changed. Is there an easy way out I didn't find or is it really a pain to track with GTM on SPA?
This was asked quite a while ago. With the current feature set of GTM, you can easily set up SPA page tracking without much trouble.
First, go to Triggers and create a new trigger. Select History Change as the trigger type. This will create a trigger that fires every time the location history changes.
Then create a new Tag of Universal Analytics type and set it up as per the screenshot below.
[
As for the trigger, set the previously defined History Change trigger, and you're done. Every time a navigation occurs in your SPA, a page view event with the proper page path will be triggered.
EDIT: as trognaders pointed out in a comment, this does not track the initial page view. To remedy, simply add an additional trigger for your tag that fires on the Page View event (All Pages). See screenshot below.
You definitely need to push events into the dataLayer which you can then trigger a GA page view tag in GTM. So to push an event into the DL:
dataLayer.push({'event':'virtualPageView'});
Then setup a trigger called 'vpv' which fires on a custom event called 'virtualPageView'. Add that trigger to a GA tag.
The best thing to do is also send through the details of the virtual page when you send the event. This way you can set up variables that pull these dataLayer property values into the page view call. So you might do this:
dataLayer.push({
'event':'virtualPageView',
'page':{
'title':'contact us',
'url':'/contact'
}
});
So you'd setup a variable called 'DL- page title' (for example) which is a dataLayer value of 'page.title' and another variable called 'DL - page url' which is a dataLayer value of 'page.url'.
You then setup a new Universal Analytics tag which has all your usual pageview settings but with 2 'Fields to Set' (under More Settings). Set 'title' to {{DL-page title}} and 'page' to {{DL - page url}}
Finally set the trigger to 'vpv' and you'll find everytime you push the event + data into the datalayer you'll get a pageView fired off with your virtual page's title and virtual url.

Using Google Analytics, if I explicitly log an event using _trackPageview, does that count as a 'real' page view?

For example, if I have a news page that's already being tracked via GA and I add a javascript event to capture clicks on a specific link to the news page (e.g. navigation) am I then 'double counting'?
If a fake pageview is not beneficial in this situation, and from your description that you're looking to track an engagement click on your page, use Event Tracking instead of Pageviews.
Tracking a click/event is easy (especially if you're already using Javascript). The best part is that this event is not considered a page view, keeping those stats safe.
The implementation is simple and allows for quite a bit of customization:
_trackEvent(category, action, opt_label, opt_value)
Below is an example of a link that's been encoded with an event tag:
Play
Here's the Google Analytics resource page on Event Tagging:
http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
Well it's not a real page view, but Google Analytics thinks that it is--i.e., it shows up in your pageview counts.
Fortunately, it's easy to filter those so they don't contaminate your pageview data.
So for instance,
_gaq.push(['_trackPageview', 'unique_virtual_pagename']);
So in your GA Browser, you'll see the number of clicks actually shown as the number of pageviews of *unique_virtual_pagename*, which is not good.
There are a two ways to fix this (that i am aware of): (i) set a temporary filter at the bottom of the pageview table; or (ii) set a persistent (c*ustom*) filter in your Admin Panel (which i think is best) to remove pageviews having only the name *unique_virtual_pagename*, or whatever name you've chosen. This will of course take up to 24 hours to set, so the best plan is to set the filter first, then add the javascript to your page. so the filter is active when you begin collecting clicks.
But that just solves the problem of disaggregating these virtual pageviews from your real pageviews, you still need a way to count/record them.
I prefer to create a separate profile in these cases. So first, i filter the virtual pageviews from my actual pageviews using a custom filter, then i create a new profile which has another filter excluding everything but these virtual pageviews. I usually give that profile a name based on the event.
What you're doing is registering what's called a 'virtual page view'. To GA it's seen as a real page view and shows up in your content report's and page view counts etc. This is often useful if you want to show a page view for media that GA can't track. It's also commonly used to count an event, such as a button click, as a goal conversion.
If you just want to record the event and not count a page view you should look at using GA event tracking instead.

Resources