Categories: Working with Google Tag Manager :

Analytics events with tag manager

Showing 1-33 of 33 messages
Analytics events with tag manager Michiel VL 11/21/12 4:09 AM
Hello

I can't seem to track events in my Google Analytics account using the Tag Manager. 
This is how my setup looks like:

I have two tags in my container:
  • Google Analytics tag for tracking pageviews;
  • and another Google Analytics tag to track events.
I've setup the tracking parameters with custom macros and added the right code to my website ( onclick="dataLayer.push({'categorie': 'quote', 'event': 'click', 'label': 'open form'}) )

Still, I cant see any events occurring within Analytics.

Any ideas?

Thanks!
Re: Analytics events with tag manager Michiel VL 11/21/12 5:43 AM
Problem solved!
Re: Analytics events with tag manager DancoNestorov 11/23/12 12:17 AM
Hi Michiel,

Great that you have solved you issue. Can you help out with mine?


We have implemented GTM for out site www.apollo.se for tracking pageviews.
On the other hand we are tracking events on some links via google analytics event taggings(_gaq.push(['_trackEvent').However, I don't see data in my event reports in GA.

I did I check with WASP, and it shows me that the event fires, but the ‘’UA’’ number is‘’UA-XXXXX-X’’. So I assume GA doesn’t know in which account to send the data. How we can solve this if I still want to keep my present set up?

many thanks
Re: Analytics events with tag manager abhinay dutta 11/23/12 12:54 AM
hi Danco,

_Gaq.push won't work with GTM as we remove traditional js code while using GTM and _gaq.push works with traditional approch.
You need to use dataLayer.push in order to trigger events.

-abhi.
Re: Analytics events with tag manager DancoNestorov 11/23/12 7:03 AM
Hi, thank you very much for your info.
But when this change happend? I was in touch with Google person before we implemented it and i got answer that it will work with the traditional method as well.

Is there any work around?

D

Re: Analytics events with tag manager abhinay dutta 11/23/12 7:12 AM
hi Danco,

I can't comment abt that..But the method i am saying works fine with me...i've implemented event tracking using dataLayer and it work pretty smooth for me..

Re: Analytics events with tag manager Michiel VL 11/23/12 7:24 AM
Hi Abhinay

Thank you for commenting.

I previously stated that the problem I had registering events in Analytics was solved. Unfortunately, I still can't see any event being registered.
Could you describe to me how you made it work?

I now only trigger the tag when an event should be registered, like this:

onclick="dataLayer.push({'event': 'GAevent', 'eventCategorie': 'quote', 'eventAction': 'click', 'eventLabel': 'open form'})

eventCategorie, eventAction and eventLabel are the macros equal to the event tracking parameters for Google Analytics.


Thanks! Michiel


Re: Analytics events with tag manager abhinay dutta 11/23/12 8:04 AM
hi Michiel ,
just use this.

onclick="dataLayer.push({'event': 'eventName'});

And in GTM fire this event when macro 'event' equals 'eventName'...
And use httpfox for testing, it will show all the calls to GA servers on the web page itself.Need not to wait for GA to refresh data..

A question from my side...Have you tried using Cross domain tracking with GTM...How to set up that??

Thanks
-abhi


Re: Analytics events with tag manager Michiel VL 11/24/12 2:15 AM
Hi Abhi

Thanks for the response.

I believe i'm doing the exact same thing as you suggest, the only difference is that i'm also pushing the category, action & label along with it. 
In my example, whenever an event named 'GAevent' occurs, GTM triggers the Google Analytics event tag. 'I've tested this using the developer tools in Chrome, and it seems like whenever its triggered, it also communicates with GA.

However, it seems like every time an event occurs GTM is putting a new script on my webpages:

<script type="text/javascript" async="" src="http://www.google-analytics.com/ga.js"></script>

After triggering the event 6 times on the same page, I have the script above 6 times in the head-section of my website. I don't think this is normal, so i must be doing something wrong.

Do you have different tags set-up in GTM for page views and events?
We all know that for page views the tag should be triggered on every webpage (in most cases). But how about the tag for events? Should it be triggered only when an event occurs (which results in adding scripts to the page like mentioned above)? Or should it also be loaded on every webpage in which case every macro with data that equals the event tracking parameters set up for the Google Analytics Event tag is automatically pushed to Google Analytics?

To bad that Google hasn't provided decent information on this subject.

Cross domain tracking can have multiple scenarios, each with different solutions. I'll give an example of the most common ones.

To set up cross domain tracking between Multiple Domains, do the following:

You have to create different Analytics tags for all the top-level domains you want to track (in this example i'm going to use site A en site B)
Start by setting up the tag for site A:

    1. Create a Google Analytics tag and set the firing rule to all pages on that particular domain only.
    2. Under 'more settings > Domains and Directories' choose 'Allow linker' and set the 'Set domain name' to site A.
    3. save
Do the same for site B, only this time set the firing rule to only match pages for site B and set the 'Set domain name' to site B

 
For tracking a domain and its subdomains:

You can just use the same tag across all subdomains. You just have to set the 'Set domain name' to the top level domain.
Say for instance you want to track www.example.com and test.example.com. The 'Set domain name' would be 'example.com'


To track multiple top level domains:

Do the same as described above, but also set 'Allow linker' to true

For more information about cross domain tracking you can check out the developers page on Google:

Hope this helps

Regards,
Michiel




Re: Analytics events with tag manager abhinay dutta 11/24/12 2:43 AM
Hi Michiel,

yes, i've different tags for events and page views.
Follows these steps to get an event triggered -
1.put this code in onclink="dataLayer.push({'event',"eventName"});"
2.create new tag.Select "events" in "Track Type"  dropdown.
3.here you have to give category,action, label(Not on page).
4Add rule as to when fire this event.In rule select macro as event and put condition equals to 'eventName'(this is name you mentioned in onclick's 2nd parameter)
5.Save n publish.


Thanks for detailed explanation for cross domain tracking.
i'm following the steps you have mentioned. I need to set this up across 2  top domains.
I've created 2 containers for 2 different websites and on page views tag, used more setting and checked allow linker and mentioned domain name there, for both the sites.

Now, my doubt is- do i need to put any code on page or GTM will take care of every thing.If yes, then how.
And how can i test whether it is working or not?


Thanks
-abhi




Re: Analytics events with tag manager Michiel VL 11/24/12 7:38 AM
hi Abhi

That doesn't really makes sense to me.
Before you can push parameters to Analytics you must set them first. So when i push eventCategorie and eventAction parameters to the dataLayer, that's when the parameters are also set for GA. 
I don't see how GA can set them otherwise, unless you set them on page load.
I've made some changes to the way my tag manager is set-up. I'll come back to this later when i have some results.

As for your question, GTM will take care of everything. Otherwise i don't see the point of why they added those options. 
I could be wrong though.

The best way to test this is to make use of Google Analytics real time. Go to both domains and you can immediately check if both are being tracked using the same Analytics property

Regards,

Michiel

Re: Analytics events with tag manager abhinay dutta 11/24/12 9:07 AM
Hi Michiel,

when u set event category from dropdown, there are options to set this value(of event category) by various ways.
you can define a custom constant string(by creating new macro), you can pick a javascript variable on page as event category, you access any DOM element for event category.
same is true for action and label.
Macros are there to get dynamic values for category, action or label.
Try creating a new macro, this will clear some air.

refer this http://support.google.com/tagmanager/answer/2644341/
Re: Analytics events with tag manager DancoNestorov 11/27/12 5:30 AM
Hi Abhi,

would you be so kind and sent a screen dump how you have configured the event tracking?  
As Michiel said, there is no much instructions from Google how to do it, and I am pretty newy in GTM.

many thanks.
D

abhinay dutta 11/27/12 6:57 AM <This message has been deleted.>
Re: Analytics events with tag manager abhinay dutta 11/27/12 7:04 AM

Create a tag like this-
PFA-Googel Tag Manager_Event.png

Now, for Category - create a new macro like this-
PFA-Googel Tag Manager_Macro.png

Now create A rule this -
PFA-Googel Tag Manager_Rule.png

Given the rule above, your page should have onclick as

<a href="#" onclick="dataLayer[{'event' : "ButtonClick"}];" > THIS IS EVENT TEST</a>

CLicking above link shall trigger event.
Get back, if doubt persists.

I've a problem this cross-domain tracking with GTM.Have you tried to play around with it.Please send in your inputs.
Re: Analytics events with tag manager abhinay dutta 11/27/12 7:20 AM
the example above shows when you want to have category/action/label to be dynamically populated at runtime(picked up from page by variable name put in textbox).
else you always have option (dropdown where Javascript variable is selected) to make these constant string.
Re: Analytics events with tag manager Michiel VL 11/27/12 7:21 AM
Danco, Abhi

You can also specify the category, action, label and value using the dataLayer.
Like this:
 
onclick="dataLayer.push({'event': 'GAevent', 'eventCategory': 'quote',  'eventAction': 'click', eventLabel': 'open quote form from the main menu'})

Just create macros as a dataLayer variable for eventAction, eventLabel and eventCategory and set those as the event parameters when creating a tag for Google Analytics (track type: event).
To fire the tag, just set the event to 'GAevent'. 

Tip: Make sure you are consistent when creating categories and actions!
Another Tip: Use Google Analytics debugger in chrome to see what data is being send to GA 


@Abhi: Everything is working fine for me now, seems I had a typo in one of the rules that I overlooked :s

Can you explain what's wrong when trying to implement cross domain tracking?
Re: Analytics events with tag manager abhinay dutta 11/27/12 7:25 AM
Hi Michiel,

I've got 2 domains-
 www.domain1.com
 www.domain2.com

I've created two seperate containers for both of them.
I've set Checked 'allow linker' and set domain name to '.domain1.com' & '.domain2.com' in respective Page view tags in both container.

Now when I test cross domain tracking, it does not work.

I think i need to do something like this in domain1's links to domain
 onclick=" dataLayer[{"_link" : "http://www.domain2.com"}];"
  as we do in traditional approch.
 
I tried doing this but it doesn't work. 
Re: Analytics events with tag manager DancoNestorov 11/27/12 2:22 PM
Hi Abhi,

Have problems making working out.

This is how I have set it up.
First I create 3 Marcos for the event category, action and label.For all i use macro type ''javascript variable''.

Category: Apolloflex
Action: Spots
Label: Homepage –medium bottom spot

Then i create 4th marco with macro type ''datalayer variable''
Data Layer Variable Name: Homepage_MBS

Then i create the tag (track type:event). From the category, label and action drop downs I select the first 3 macros i created (Apolloflex, Spots and Homepage –medium bottom spot)

I add a firing rule
Homepage_MBS contains Homepage_MBS

the website in question is www.apollo.se And below is how is set up in the source of the page

onclick="dataLayer.push({'event','Homepage_MBS'});

Can you pls go to the homepage of Apollo, take a look and let me know what i am doing wrong. I am not a webmaster or sth, so it's hard to make it work.

Super many thanks

Abhi, unfortunately Idon't have any experience with cross domain tracking to help you out.
Re: Analytics events with tag manager abhinay dutta 11/27/12 8:20 PM
Change rule to
'event' contains 'Homepage_MBS',
Also correct sysntax is
 onclick="dataLayer.push({'event' : 'Homepage_MBS'});
Also you must set JS variables(with same name as mentioned in macros) on page before event is fired, so that container can access those var and pass on to server.
-abhi
Re: Analytics events with tag manager bluks 11/28/12 2:21 PM
Hello!

Is there any way to combine all events in one or few tags in tag manager (maybe within page scale)?
Because they inflates all tag section in TM - or there is no other choice as for each event - separate tag.




Re: Analytics events with tag manager alexgbrown 11/28/12 6:16 PM
Hi Michiel,

Thanks for posting the example.  On this occasion It was actually more helpful looking at this than all the comments and screen grabs provided.

A small observation about the code provided... its missing ' at the start of the eventLabel' description and also missing " after the bracket close at the end of the string

onclick="dataLayer.push({'event': 'GAevent', 'eventCategory': 'quote',  'eventAction': 'click', eventLabel': 'open quote form from the main menu'})


Corrected version for others to copy + paste

onclick="dataLayer.push({'event': 'GAevent', 'eventCategory': 'quote',  'eventAction': 'click', 'eventLabel': 'open quote form from the main menu'})"


Debugging onclick event tracking in GTM preview mode is pretty hard if you're not really observant.  The tag 'fire' message disappears quickly.  For the folks at Google, it might be worth having a preview/debug mode than retains the calls log in sequence just in case people blink when testing.

Tip for Chrome debugging method, don't forget to go into the optional settings wheel in the bottom right-hand corner and on the 'General' tab by 'Console' tick the box that says, "Preserve log upon navigation"

Personally, I'm a massive fan of using Charles for debugging.  It logs almost everything and works well when testing on mobile/tablet devices using a proxy.

Thanks again for sharing this approach.  Really useful.

Cheers,
Alex

Re: Analytics events with tag manager Google Product Learner 12/21/12 9:04 AM
I've finally managed to get this done and I made a tutorial with screenshots. http://pr0v.com/gtm-eventtracking/. Hope it helps out.
Re: Analytics events with tag manager Vimlesh Maurya 2/18/13 5:43 AM
Hi Abhi/Michiel,

Do we need to put Data Layer in Body Tag for tracking events, if yes then again we are depending on IT team to implement these tags.
Is there any way to track events directly by GTM.

Re: Analytics events with tag manager abhinay dutta 2/18/13 6:37 AM
one solution i can think of - write custom html tag with javascript u want to execute on click (like-
$("#id of button").bind(click,funtion(){
_datalayer{......}
});
. drop this on page.

thanks. 
Re: Analytics events with tag manager (unknown) 3/6/13 12:24 PM
Hi Michiel,

http://www.marketingoptimizations.com/setting-up-event-tracking-in-google-analytics/

This post will give you what you need!
Let me know if i can be of any more assistance!

Thanks,
Dorian

Re: Analytics events with tag manager DeZetaGe 3/21/13 1:55 AM
Google Analytics Debugger for Chrome, what a really cool tool! Thanks so much for the link.

Michiel, I'm experiencing something similar than what you said. I've set up everything as you suggested but it still doesn't work.

I can see in GA Debugger that GTM is sending the event for GA right:

_gaq.push processing "_trackEvent" for args: "[transaction,moreThanOneArticle,,,]":

I also can see the values sent to GA, and I think they are right:
Hit Type                 : event
Event Name               : transaction
Event Type               : moreThanOneArticle

In GA, I've set up a goal using the following configuration:
Goal type: Event
Category that matches: transaction
Action that matches: moreThanOneArticle

Still, I cant see any events occurring within Analytics.

Any help would be very appreciated.

Regards,

David

Re: Analytics events with tag manager claudia_k 3/21/13 1:54 PM
Hi David,

When you check the data with the GA debugger for Chrome - did you have a look at the account number? Does that account number match yours?
Also have a look in Google Analytics in the Content>Events report - do the events appear here? Sometimes it takes a while until event-based goals appear in the goal reports, but any events should also appear in the Content>Events report.

Good luck

Claudia
Re: Analytics events with tag manager DeZetaGe 3/22/13 1:00 AM
Hi Claudia

I SOLVED my error. I'm not sure but I think the key is that I typed the Category and Action fields (in GTM and GA also) without ''.

That's what didn't work:


Category that matches: transaction
Action that matches: moreThanOneArticle

Then I did these changes:
Category that matches: 'transaction'
Action that matches: 'moreThanOneArticle'

And now it works fine.

> Also have a look in Google Analytics in the Content>Events report - do the events appear here?

Yes, they do! Very useful information.

> Sometimes it takes a while until event-based goals appear in the goal reports, but any events should also appear in the Content>Events report.

Thank you so much Claudia.

Re: Analytics events with tag manager abhinay dutta 3/22/13 1:10 AM
Hi All,

There's a way to check your data on GA servers and by this way you can see your data quite early than regular GA console.

This is google data explorer API, very helpful.
http://ga-dev-tools.appspot.com/explorer/?csw=1

Explore this. Should you have any trouble using this, reply back to me.

Thanks,
Abhinay.
Re: Analytics events with tag manager DeZetaGe 3/22/13 1:30 AM
Very interesting tool!

I've been doing some tests and I've noticed that events don't appear in queries in real time (as I expected). Do you know the delay on refreshing data? Sorry if my English is not accurate, I hope that you understand what I mean.

Thank you so much for your comment. I'm so happy to have found this fantastic forum.

David
Re: Analytics events with tag manager (unknown) 12/27/13 2:37 AM
HI GUYS,

If you've got the UA-XXXX issue, just post a simple command before your gaq.push.... command as follows. This will reinitialize GA script for any account you need. so put in your account instead of the whole bracket section:

_gaq._createAsyncTracker('[Your UA-XXXXX-X Account here]');

for example:

_gaq._createAsyncTracker('UA-12345678-9');

This solved the problem. It's a quick fix.

Re: Analytics events with tag manager abhinay dutta 2/17/14 9:40 AM
here is quick tutorial to export bulk GA data using the GA data explorer API,


-Abhinay
More topics »