Google Analytics Tag Manager fails - google-analytics

Google recently released a new feature "Tag Manager"
https://developers.google.com/tag-manager/devguide#migration
https://developers.google.com/tag-manager/reference#varnames
Do you know any success stories and give successful site html-examples?
I was not able to make Events working.
Here is my site, but it fails. You can see which code is inside by Ctrl+U in FF.
http://landkey.org
When I click on test button which supposed to send this event: .....
input type="button" onclick="dataLayer.push({'bubbles_event' : 'ANCHOR_..... '}); alert('clicking'); " value="bubbles"
..... nothing is sent in "Net" pane.
In dashboard of "Tag Manager"/Container/Tags, I set up a tag, TrackType as "Event" setup event rule, and double checked this few times.

I'm wondering if you're running into an issue where there's a collision on the 'event' namespace. We've autocreated the 'event' rule / macro type to map directly to dataLayer.push({ 'event' : event_name }). This only works if you use 'event' as the key.
In your code example, it looks like you've chosen a different name for your event, called 'bubble_event'. The simplest suggestion I have for you is to just rename 'bubble_event' to 'event' in your data layer. That should hopefully work.
If you're attached to 'bubble_event', then you could create a macro of type Data Layer variable, where the data layer variable name is 'bubble_event'. Then you could create a rule where Bubble Event = whatever value you're looking for. However, it's best practice and recommended to just use the 'event' syntax wherever possible, since then you can consolidate all your events.
Give that a shot and let me know if you're still running into issues.
Cheers,
Laura

Related

Trouble recreating Google Analytics (UA) events in GA4

I have a bunch of mp3s and an audio player on my site. In GA3 (UA) I had an event that fired every time I hit the play button on a specific track. The event name was jPlayer, the track in question is the variable 'mediaName', which is the name of the mp3 file which is derived when I click play. In my code, mediaName is a string that gets sent out to GA. i.e. mediaName might be 'mycooltrack.mp3', or 'anothergoodtrack.mp3'
ga ('send', 'event', 'jPlayer', mediaName);
After reading the GA4 docs, I guessed that I needed to make a custom dimension, called "Track" which took the User Property/Parameter: mediaName.
So the new code in my function looked like:
gtag('event', 'jPlayer', {
'Track': mediaName
});
But after several days this hasn't been working either.
I guess I don't really understand what dimensions are and how to send an event with an 'on-the-fly' name variable to GA4, like I've been doing with UA for years.
You need to first create the event in GA4 interface. https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#zippy=%2Cin-this-article%2Creserved-prefixes-and-event-names%2Cweb
It is under "Configure" on the left-hand side. Then go through the steps.
Your configuration will look something like this, if you really like the "jPlayer" event name, then just replace "audio_play" with "jPlayer"
The code you used is still relevant and can stay the same, I'd just write "track" in lowercase.

Google analytics push custom channel grouping

Is it possible to push custom channel group into Google analytics in a similar way as events? For events I use this code:
_gaq.push(['_trackEvent', 'Popup - displayed', 'Popup displayed - Popup Id 5', 'This is popup title']);
Now I want to push new custom channel group Popup displayed each time user get served popup so I can compare results with Organic search without popup, Direct traffic without popup with organic search with popup.
I would like to accomplish something like this:
Tnx!
With the current Google Analytics version you could use a set call with your tracker object to overwrite campaign data and then create a custom channel definition that matches your custom data:
trackers = ga.getAll();
tracker = trackers[0];
tracker.set('campaignMedium', 'withPopup');
No idea how you would do this with your version of Analytics which is deprecated. Also this may have side effects (like loosing the original campaign data).
However you may simply create two segments, one for users who have seen the event and those who have not. Since you can select multiple segments this allows for a comparison without changing anything in the code.

Receiving unexpected server calls

In adobe analytics I try to implement link tracking for all links can be found in a page using this:
$(document).on('click', 'a', function() {
s.tl(this, 'e', 'external', null, 'navigate');
return false;
});
Try to test it using a page like this
The extra calls are likely coming from how you have Adobe Analytics configured. There are a handful of config variables that will cause extra requests depending on how you set them (on their own and/or in relation to each other).
Here is a listing of Adobe Analytics variables for reference. These are the ones for you to look at:
s.trackDownloadLinks - If this is enabled, any standard links with href value ending in value(s) specified in s.linkDownloadFileTypes will trigger a request on click. Generally, this is to enable automatic tracking for links that prompt a visitor to download something (e.g. a pdf file).
s.trackExternalLinks - If this is enabled, any standard links with href NOT matched in s.linkInternalFilters OR matched with s.linkExternalFilters will trigger a request on click. Generally, this is to enable automatic tracking for links you count as visitor navigating off your site(s).
s.linkInternalFilters - If you have either of the above enabled, clicking on links may trigger a request, depending on values here vs. what you enabled above vs. what you have in s.linkExternalFilters. Generally, this should include values that represent links you do NOT want to count as navigating off your site(s).
s.linkExternalFilters - If you have either of the above enabled, clicking on links may trigger a request, depending on values here vs. what you enabled above vs. what you have in s.linkInternalFilters. Generally, you should never set this. It's intended for edge-use-cases for people who know what they are doing and have a complex site eco-system and definitions of what counts as internal vs. external.
s.trackInlineStats - This is for clickmap/heatmap tracking. This may or may not trigger an extra request, depending on how a lot of different stars align.
In addition to these, you may already have some plugins or other custom code that triggers click tracking. For example, there are linkHandler, exitLinkTracker, and downloadLinkTracker plugins that you may have included in your code that may play a part in extra requests being triggered.
Finally, more recent versions of Adobe Analytics code may trigger multiple requests depending on how much data you are trying to send in the request (whereas older versions just truncated the request, which resulted in data loss).
In any case, the long story short here is if you are looking to roll your own custom link tracking, you should make sure the above variables/plugins are removed or otherwise disabled.
But on the note of rolling your own custom link tracking.. I'm getting a sense of de ja vu here, like I already made a comment about this relatively recently in another post, over this exact same code... but generally speaking, this is not a good idea:
$(document).on('click', 'a', function() {
s.tl(this, 'e', 'external', null, 'navigate');
return false;
});
You are wholesale implementing exit link tracking on every single link of your page. And you are giving them all the same generic "external" label. And the native exit link reports are pretty limited and useless to begin with, so ideally you should also pop an eVar or something with the exit url or something.
But more importantly.. unless literally every single link on your pages are links that navigate your visitor off-site, this is not going to be useful to you in reports in general, and it's even going to ruin a lot of your reports.
I can't believe (or accept) that you really want to count every link on your pages as exit links..
I assume s.tl does an ajax call.
It should then forward the link to the href of the link - if the link is allowed to be followed immediately, the ajax call will be interrupted which seems to be what you see
You may want to change to
$(document).on('click', 'a', function(e) {
e.preventDefault();
s.tl(this, 'e', 'external', null, 'navigate');
});
I found this article when looking to see what s.tl is https://marketing.adobe.com/developer/forum/general-topic-forum/difference-between-s-t-and-s-tl-function

How to Track Store Locator Search terms in Google Universal Analytics

I am in the process of setting up enhanced Ecommerce for GA and have had a few requests of additional of what else the client would like to see in their reports. Once of which is
"Where can i see a report if the locations that a use types in when they use the store locator"
There is already an internal search functionality thats been set up and is tracking the search terms people are typing when looking for products, but i'm not sure if i would need to set this up as a second search terms report or if it's something different?
The URL of the page is different to the internal search results and is www.domain.com/store-locator#wales|GB|0|0|0
Any insight into this would be really helpful.
Thanks,
Roxi
As to me knowledge, you are not able to use bookmarks (#something) in GA for internal site search setup. Only GET and POST parameters are allowed. In your situation I think the best solution is to use GA events to send the data about used location each time the user is using this functionality. You need to include addition ga() function call to track those events. Info about how to set it up you could find here: event tracking. After setting things up, you will see all the info about number and type of called events in Behavior -> Events reports section in GA.
Example code:
<button onlick="var hash_location=window.location.hash;ga('send','event','Locator',has_location)">Click me</button>
With such function new event will be send to GA with Event Category=Locator and Event Action=hash in the url. You have some complicated hash, so most probably you need to extract first some info from this using regular expression. Example to get first item from |-separated list in the hash:
var pattern = new RegExp('[^#|]+');
var hash_location = pattern.exec(window.location.hash)[0];

How to track custom parameter with Google Analytics and utm.gif

The situation
I'd like to use GA to track some serverside operations. That's why I cant make use of the GA JavaScript functions. But, as you might know, you can request the utm.gif right from your server. This already works fine.
The Problem
I'd like to trackt custom parameters. But I have no idea how to add them in the right format to the url-request
This one should do the custom parms. But I didn't get any results in GA.
utme=5(Init*load_success*http://www.mydomain.de)8(userstatus)9(fan)11(2)
Full list of params:
ref ts
utmac UA-XXXXXX-5
utmcc __utma=186215409.1789216404.1265552708.1280074861.1280493144.21;+__utmz=;
utmcs ISO-8859-1
utmdt Button
utme 5(Init*load_success*http://www.mydomain.de)8(mycustomvar)9(mycustomvalue)11(2)
utmfl -
utmhn mydomain.de
utmje -
utmn 1114675642
utmp button
utmr http://www.mydomain.de
utmsc -
utmsr -
utmul de-de
utmwv 4.5.7
not sure what's going wrong, given what you posted, but how about you write out what you want to send the traditional way (with javascript) and put it on a test page. Use firebug or whatever to grab the requested url that's built and compare it to what you have now.
The value of the utme gif Request parameter is encoded by ga.js--it's the only one that is, as far as i know.
Calling __trackEvent is the usual way to set the value of utme. These are client-side events though, which is no doubt why you are trying to set utme directly.
So if you just want to bind 5(Initload_successhttp://www.mydomain.de)8(userstatus)9(fan)11(2) to the variable utme, and you can't rely on user-behavior to trigger that binding, then here's what i suggest:
Pack your data into a 'custom variable' scoped to the page--this way, when the __trackPageview() is called, the value will be set.
Here's the analytics code required in your HTML to implement that:
The method signature for a custom variable:
pageTracker._setCustomVar(slot, // integer between 1 and 5, inclusive (just use '1')
name, // user-defined name for the custom variable
value, // string representing the value for the custom variable
scope, // you want '3' for page-level (an int, not a string though)
);
Within the HTML (order matter, of course):
pageTracker.__setCustomvar(1, "A Name", "A Value", 3);
pageTracker.__trackPageview();
A key point here is that the parameter 'value' can be set dynamically, so for the 'value' parameter, i guess you want to pass in 5(Initload_successhttp://www.mydomain.de)8(userstatus)9(fan)11(2)
Finally, here are the two key sources (Implementation Guide, Usage Guide) on Custom Variables from the GA Team

Resources