track URL click on email with GTM - google-analytics

I was wondering how can we track a click on a link sent via email using Google Tag Manager.
I mean, the user gets an email that contains an URL to our website, we would like to know if the user clicks on that link.
Is it possible to do it all just using the GTM console or do we have to add some extra code to fire up the event?

To be pedantic, you cannot track the "click" on the link since the mail itself does not contain tracking code or GTM code.
However you can append a parameter to the link (if you are using Google Analytics you should tag all of your links with campaign parameters in any case). Then you can check within GTM (e.g. via a url type variable with component type set to query string) if the parameter is present and then fire your tags accordingly.

Related

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 tag is fired but event does not show up in Google Analytics Real Time Events Tab

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.

How do I track Virtual Pageviews in the new version of GTM?

I've attempted to use the new version of Google Tag Manager to track virtual pageviews and send those to Google Analytics, but they don't seem to be sending properly.
For my Trigger, I've used the builtin History Change event type and have placed that in a tag with my Google Analytics id. The tag is set to Page View track type.
In Google Analytics, I see a pageview, but it just says the user is on the root directory. Also, I'm working in Localhost.
Is there something I missed?
I'm not sure to get the complete description of your setup but maybe an other way of tracking your virtual pageview could be directly by adding data layers directly in your code.
dataLayer.push({
'event':'VirtualPageview',
'virtualPageURL':'/order/step1',
'virtualPageTitle' : 'Order Step 1 – Contact Information'
});
For the trigger, you will then be able to send the fire on of your virtual pageview as a event matches VirtualPageview.
Your Tag need to be set up as a pageview.
Also, using this article for GTM v1 : http://www.lunametrics.com/blog/2014/09/10/fire-virtual-pageview-google-tag-manager/, you can set up your {{virtualPageURL}}
In GTM V2, in your tag, you will have to use the - More settings / Field to set field Name = Page, Value = {{virtualPageURL}}.
Are we talking here about a one page iOS/Android App?

gtm tag manager virtual pageview (URL rewrite)

Current tracking of the checkout funnels is done through Pageview using virtual pageviews via
_gaq.push(['_trackPageview', '/checkout/login']);
_gaq.push(['_trackPageview', '/checkout/address']);
which has been hardcode into the webpage.
We are now updating to UA through GTM with enhanced Eccomerce. I would still like to continue to track the checkout funnels with the current method while implementing the Enhanced Eccomerce step 1 / step 2 codes.
My question is If i can fire a datalayer push to overwrite the url which the {{url path}} macro in GTM will track so instead of using /pws/secure/CheckOut.ice?&checkout=true&secure_from=checkout as a goal URL I can use the virtual urls "/checkout/login" and "/checkout/address".
*for some reason only the login and address pages of the checkout are on the same URL.
Would something like this work
dataLayer.push({
'url path':'/blah/blah'
});
If not is there a way I can use the lookup macros in GTM to do Document Path = {{Virtual URL}} (IF it not empty) or {{url path}}. Basically I dont want to have to create multiple tracking codes for each of the checkout funnels with the virtualURL in the Document path. Not to mention how I would get GTM to recongise that one second the URL is a login page and the next it an address page.
Any ideas would be really appreciated
That's correct, you can use the data layer to push your own URL path to Google Tag manager. First you need to set the path in the data layer as you mentioned.
dataLayer.push({
'url':'/foo/bar'
});
Then, in Google Tag Manager, you can do the following :
Go to the tag that handles your GA "page views"
In "More settings", look for "Fields to set"
In the field name, pick {{url}}
For the value, you should create a macro that gets your "url" from the data layer:
As I understand, you can use basic virtual page view behavior by creating GA tag with rewrited url. This tag will be fired, when two events will happen - one for every page view that you want to track. You will only need to add two pushes to dataLayer for events - event itself and dataLayer veritable with url. For example, it can be something like that: dataLayer.push ({'event':'first-event','custom-url':'/my/custom/url1'}).
In GTM you should create a macro, that gets the value of 'custom-url' dataLayer veritable, and use it to rewrite url in your GA tag.

Use Google Analytics to track Google Form submissions

I'm using Google Forms (a Google Doc spreadsheet with an automatically generated form that the user can fill in to submit their details) and would like to track the submission of the form as a virtual pageview in Google Analytics so that I can measure conversions. Does anybody know if this is possible?
While Crayon Violent is correct about the built-in capabilities, there is a viable option: If you're able to host the Google Form HTML on one of your own pages, you can treat it like any other form (you can literally copy and paste the form HTML from the form page). As long as you leave the inputs unmodified, and the form action remains as its presented, it will post successfully to the form, regardless of where it is hosted from. (You can remove the styling elements if you wish.)
You can see a sample of that here: http://jsfiddle.net/PVBqX/2/
And you can see the data record just fine in the Google Spreadsheet here.
And, if you use Firebug or Webkit inspector, you'll see that the virtual pageview is sent:
There is an alternative solution to track pageview in Google Analytics using an image impression inside the Google Doc which I have been using it in my spreadsheet.
Check out the following link for the guide of explanation on how this works:
Tracking-google-sheet-views-with-google-analytics
For example, using little Apps Script will include the sheet key and locale in the image url (to include this you your own project open you Sheet and then Tools > Script editor and paste the code in):
function getGABeacon(tid){
var id = SpreadsheetApp.getActiveSpreadsheet().getId();
var locale = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetLocale();
return 'https://ga-beacon.appspot.com/'+tid+'/sheets/'+id+'/'+locale;
}
Then in the Sheet we can then use the cell formula like =image(getGABeacon("UA-48225260-1"))
EDIT
You can also build a tracked URL and pass it to the beacon on targetted page using this function
var trackURL = SpreadsheetApp.getActiveSpreadsheet().getUrl();
Probably you should just use Url shortner tool like https://goo.gl/ or https://bitly.com/ to get analytics on how many clicks are made and little bit of analytics like locations, browsers etc through them.
You can add Google Analytics in general by setting up a new page which includes the form using an iFrame and then adding the Google Analytics tracking code right before it.
I found a service that does exactly that and is completely free. It's called GFormAnalytics. It will generate a new link for you and then you share that new link and it will track your forms with your own Google Analytics tracking code.
Check it out here: https://GFormAnalytics.com
Here is what I did using Zapier (free basic plan), no coding needed:
How to use Zapier to trigger a goal conversion in Google Analytics (used with Google Tag Manager) when an embedded Google Form is completed
In Google Tag Manager click on Triggers to create a new trigger.
For trigger type, select "custom event."
Set it to trigger on "Some Custom Events."
Set the trigger to fire when the Page URL contains a unique part of a URL e.g. "/pages/contact."
Name (e.g. "Contact Form Submitted" and save the trigger.
Click on "Tags," then click "New" to create a new tag.
For tag type select "Universal Analytics."
For Track type select "Event."
Under "Event Tracking Parameters" for "Category" enter "Form Submission."
For "Action" enter "Submitted."
For "Label" enter "Contact Form."
Leave "Value" blank.
Under "Non-Interaction Hit" select {{Event}}
Under "Google Analytics Settings" select {{Google Analytics}}
As the trigger for this tag select the trigger you just created, "Contact Form Submitted" (or whatever you named it in step 5) which should show as a custom event.
Name the tag (e.g. "Contact Form Submission") and save.
Press "Submit" in the upper right corner to activate the new tag.
In Google Analytics, select the gear icon in the bottom left (Admin settings).
Under "View" select "Goals."
Select "Create New Goal."
Select the "Submission" goal template in step 1.
In step 2, under "Type," select "Event."
In step 3, for "Category," "Action," "Label" enter exactly the same thing you did in Tag Manager in steps 9-11 (case sensitive).
Leave "Value" blank.
Save the goal.
In Zapier, select "Make a Zap!"
For the Trigger App, select "Google Forms."
Select "New Response in Spreadsheet."
Connect your Google Forms account.
Choose the spreadsheet connected to your form.
Under "Worksheet" choose the "Form responses" that shows up in the drop down menu.
Select "Google Analytics" as your action app.
Select "Create a Measurement."
Connect your Analytics account.
Select your Account and Property.
Under "Type," select "Event."
For "Category," "Action," "Label" enter exactly the same thing you did in Tag Manager in steps 9-11 (case sensitive).
Leave the other fields blank.
Test and activate the zap.
Go to your website and fill out the form.
After at least 15 minutes (enough time for Zapier to have checked the spreadsheet linked to your form) check your goal conversions in Google Analytics to verify that the zap is working.
If you Edit the Form and select Responses menu, then select enter Tracking ID, paste in your tracking ID in and you will get page views as he goes to each page including the confirmation page which has Page Title of "Thanks!". This works even putting the link to the form in an email. Works great, tracking the mail open, then the pages and submit of the form, but I haven't figured out how to pass the user ID so both types of events carry the same user ID.
not possible. You have to be able to add code to the actual file being served.
Only thing I can think of is if it lets you redirect to one of your own pages after form submission, put the code on a page you create on your own site

Resources