First of all I am new to GTM. I am trying to implement GTM video tracking on one of our site which is using JW player.
I have followed couple of articles as follows:
https://www.thyngster.com/jwplayer-video-tracking-using-google-tag-manager/
In the above one I was clueless what to do after putting the tag code as I couldn't find how to trigger that.
I also followed this link, but it didn't work either:
http://ecommppc.com/2014/11/30/track-jw-player-videos-on-gtm/
I believe I know what is going on. The code/tag, trigger, and variable he has set up in the tutorial is only what pushes the information to the dataLayer itself. The final step would be to add another variable, a tag to capture it, and a trigger to send it.
The variable you need is the dataLayer variable (Available in GTM under Variables > User Defined Variables > New > Data Layer Variable). You then give it the name of the variable in the dataLayer you want it to capture. Specifically, any of the variables in the dataLayer.push action (i.e. video_url, duration, etc).
The trigger to use in this case is the Custom Event trigger. This trigger will specifically wait for an object to be pushed to the dataLayer with the "event" variable in it. In this case, you need a trigger to wait for an event with the name "video". You can also add filters, i.e. this trigger will only fire on specific URLs, or when other conditions are true.
Finally, you need another GA Universal Analytics tag, set up to track events i.e. Track Type: Event. In this tag, set the trigger to the Custom Event trigger you made earlier, and then click into "Configure Tag". Under "More Settings", click "Add Custom Dimension". Make sure the index you are using to send it to Google Analytics is not in use in your property already; other than that it doesn't matter what index you choose. Finally, add the variable name in the "Dimension Value" field in this format: {{video_url}}. Instead of "video_url", include the name of the dataLayer Variable you created earlier.
This should get GTM to grab the variable out of the dataLayer and push it to Google Analytics every time that "event" variable is seen in the dataLayer object.
Hope that helps!
Related
I am "kinda new" to Google Tag Manager. Meaning I've created several tags, and manage several sites using it. However, I am curious if the process I have set up for Event tracking is considered a "best practice." Therefore, I am looking for ideas to improve it.
Goal: For any given website version release, I would like to assign all event tracking to a single Google Analytics Event tag.
All of the tutorials online have you entering an individual GA Event tag for each event you are tracking. This seems crazy to me, so I am hoping to avoid that by consolidating them as much as possible.
Comments?
Precondition
I am fortunate that I have access to my devs, and they are awesome at adding unique ids to everything I need to track. I am assuming ids are used to locate elements.
Create a new Workspace unique to the elements being tracked
Create a new workspace in GTM describing the events I've been requested to add. I often get short, requests from our Management to add tracking to specific elements. So I add this info to the Workspace description.
Use this workspace only for creating the events in this "release."
Create variable for the Event's Action, Label, and/or Value
Create a new Lookup Table Variable.
In the look up table, select Click ID as the input.
Add the id the Devs assigned to the element we're tracking.
Add the Action the you want assigned to the element.
Repeat so you have a complete list of all the event's ids and their corresponding Action.
Name the variable something that makes sense to you.
Repeat for the Event's Label and/or Value.
Create a Trigger for each of the elements being tracked
Go to the Triggers section and create a new Click Trigger.
Set it up so it is only triggered when the element's ClickID is clicked.
Save the trigger with a name that makes sense to you.
Repeat for each of the elements being tracked.
Create a GA Event Tag unique to this "Release" and add Triggers
Add a new GA tag with a predefined name that describes what I am tracking.
Select Events instead of pageviews
Enter the Category y'all want for the Event
Select the variables created for the Event's Action, Label, and/or value.
Add all of the triggers to the tag.
Preview the tag. If it's right, then publish the release and merge back with the main workspace.
Repeat at the next release whenever I need to add more event tracking.
I am working on one project which needs to fire same GTM tag to for two different GA account is this possible? or should I have duplicate all the same tags for two GA accounts?
There is no standard way to fire multiple properties in one tag. However I can think of two possible workarounds.
(Updated: The same questions came up on the GTM forum and naturally Simo Ahava had a solution).
One would be to create the tracker object manually in a custom html tag (the actual pageviews happen still via Ga tag templates). This would allow you to use Google Analytics plugins and there are plugins (e.g. here or here) that send hits to multiple properties.
The other workaround is to use a feature called tag sequencing. This has the advantage that you do it with "pure" GTM instead of GA plugins. I will first show the steps and explain what happens later.
The Setup
First you need to set up your tracking id as a variable of the datalayer type. As default value you set your first tracking id:
Next you create a custom html tag that will later set the second tracker id. This also sets a custom event necessary to fire the second tracker. Note that there are no triggers attached to this tag, and that it is set to "fire only once per page" (the last thing is very important! You can set this in Advanced Settings -> Tag firing options).
Then you create a trigger that uses the custom event from the previous step:
Now comes the magic with the GA tag. You use the variable for the tracking id that you have created earlier. Then you go to "Advanced Settings", expand the "Tag Sequencing" options and check the mark before "fire a tag after fires". You select the custom html tag from above (named set2ndId in my example). Then you attach a pageview trigger and the custom event trigger (called 2ndTracker in my example).
The sequence
GTM is loaded and evaluates the tracker id from the default value of the datalayer variable
The pageview trigger fires the GA tag
The tag sequencing setting fires the custom html tag that sets the datalayer variables for event and tracking ind
Since we have an event the datalayer is re-evaluated, and the new value with the second tracker id from the custom html tag is set
The custom event trigger fires the GA tag with the second tracker id
Since the custom html tag was set to "fire once per page" it is not fired again (else you would end up in a loop)
A word of caution: This is somewhat clever, even if I say so myself, but at the moment it is a bit "proof of concept". I use it without problems for pageview tracking, but I'm still working the kinks out for event tracking etc, so you have to decide for yourself if this is useful for you.
But at least it answers your question: yes, it is possible to send to multiple properties without duplicating the GA tags, but it takes some additional setup so you have to decide if this actually saves you work.
yes it is fine to fire multiple GA properties in single GTM.
Maybe this tutorial will help you:
http://www.kristaseiden.com/step-by-step-adding-a-second-ga-property-via-google-tag-manager/
I hope this helps.
I am a developer in codiva.io a java ide for students. I am using codemirror editor.
I want to track on edits (specifically a pause or timeout after last edit).
I had previously used Google analytics, and for events, we will do ga.send(). Now I'm using Google tag manager, for clicks and other events it seems we can configure using tag manager ui itself.
With tag manager, I'm not able to find how implement tracking for this.
Codemirror generates an on change event. On each edit, clear any previous timer and setup a timeout trigger to run after 200ms. (The compilation will be dive at this point, and I want to make sure to track the number of times this event happened)
If I understand you correctly:
Use you change event to have a custom event pushed to the dataLayer:
dataLayer.push({event:'compile'});
Then create a trigger of the type "custom event", set event name to "compile" and use that to fire a Google Analytics event tracking tag (if you use the GA tag template you can select the hit type via a dropdown).
The "push" method of the dataLayer ist not the native array method but a special implementation by the GTM code; GTM uses this to monitor changes to the dataLayer, and the "event" keyword tells GTM to update its internal datastructure so new values become available to tags and triggers.
With the same push you can also pass data to be used as eventCategory etc:
dataLayer.push({
event:'compile',
eventCategory:'myCategory',
eventAction:'myAction',
....
});
You then create new variables of the "dataLayer" type and enter the name of the key you want to access. You can then use the variable in your Ga tag, either by selecting it from the autosuggest list (if you click the icon right to the eventCategory etc. fields) or by typing out the variable name with curly brackets, i.e {{myVariableName}}.
Also keep in mind that the "event" keyword in the dataLayer does not relate to Google Analytics events, except in the sense that it can be used to trigger event tracking (as well as any other tag). "Event" is just a keyword in GTM to indicate that data is updated and tags can now access the new data.
I have been reading the new documentation for Google Tag Manager, and based on that have created a custom event which looks like this:
Here event is the key and the value is Shop Now Start. I am pushing this in the Data layer in my website. But at the point, where these key value pairs are pushed in my data layer, the respective tag is not being triggered.
Besides the event key/value pair, how can I go about setting a trigger that is fired when a key value pair has a certain value (e.g. userId='12')
Also, when I am setting the trigger, can I set the value to be boolean false? (e.g. isNew='true'
The problem was that my website is a single page architecture. So custom Event triggers don't work. So instead need to create a history change trigger
I am using the async version of Google Analytics along with custom variables and events. I have placed the tracking script (cut and paste from google) at the end of the section.
The custom variable is set above the tracking code in the head section. I'm assuming that Googles Analytics will send the data including the custom variable on page load. What happens if I have onclick triggered events? Will the custom variable in the head section get sent along with each event that is triggered as well?
I'm not sure how this plays out with javascript.
Thanks!
It depends on the scope of the custom variable. Page view scope will only send/report the first time. You will have to include it in the onclick code that is triggered to get it to count each click.
If you have it as a visit/session scope, in the reports, it will associate itself for each click event for the duration of the visit/session.