We are using Google Tag Manager and Google Analytics to track page views and user behaviour in a Single Page Application.
The web application has several sections designed to be beneath a specific project URL, so we have this kind of application routing:
/projects/{projectId}/section1
/projects/{projectId}/section2
/projects/{projectId}/section3
So currently our tracking works like this:
/projects/abc/section1: 3 pageviews
/projects/xyz/section1: 7 pageviews
/projects/abc/section2: 10 pageviews
/projects/xyz/section2: 10 pageviews
/projects/abc/section3: 3 pageviews
/projects/xyz/section3: 2 pageviews
We now want to also gather aggregated per-section data, such as:
/section1: 10 page views
/section2: 20 page views
/section3: 5 page views
Is there any suggested way to do so using GTM or any Analytics settings that helps us aggregating these information?
Also we want to do this without having to modify the web application (we can modify the application but we prefer it to be kept as much agnostic as possible in regards of analytics tracking).
Assuming you use Universal Analytics (and not the new Google Analytics for Apps and Web), you could create a hit based custom dimension, which would allow for a custom report with hit based metrics (such as number of pageviews - "hit based" means this is tracked per request, "session based" would store only the last value in a session). This takes some preparations in Google Analytics, but implementation-wise it can be done in the GTM interface without touching the page code (provided that page tracking is already set up correctly for your SPA).
First go the GA admin interface, to the middle column with the property settings (custom dimension are created at property level) and search for "custom definitions". Expand, click "custom dimensions", click new. Enter a name, e.g, "Sections", select "hit-based" for the scope and make sure the "active" checkbox is checked. Click "save". In the overview you will see that custom dimensions have a numeric index, if this your first custom dimension the index will be "1".
Now, go to Google Tag Manager. Enable the built-in "page path" variable. Go to custom variables, click "new", and select "custom Javascript" as type. Write some custom script to return the last segment of your path. Custom Javascript variables take the form of an anonymous function, so this could look like this:
function() {
return {{Page Path}}.split("/").pop();
}
{{Page Path}} is the built-in page (the url without protocol, hostname and parameters), the split("/") splits it along the delimiter and stores the value in an array, and the pop() returns the last element of the array, so this will always give you the bit that contains the section.
Now go to your Google Analytics tag (either the settings tag, if you want this to be send on all hits, or your pageview tags, if you want this only in pageviews; in the latter case you will e.g. be not able to filter your event reports by section). In the "custom dimensions" setting (under "more settings" in the pageview tag) click "add custom dimension". In the index field enter the numeric index for the dimension you have created in GA. In the value field, enter your "section" variable ({{Section}}, GTM variables are denoted by double curly brackets in the interface). Save, publish, wait a few hours, create a custom report with the custom dimension as primary dimension (custom dimensions do not show up in standard reports), add all hit-based metrics you want (e.h. page views) and you should be good to go.
Related
New to Google Analytics-
I need to exclude a URL for a View but still need to track events from Google Tag Manager.
Situation: I have a page which loads dynamically with different content in the same URL. EX: Start,Step1,Step2,Step3,Finish.
I needed to track all these steps separate and create a goal funnel(without a required start page).
To track these I used Google Tag Manager to create Page Views(virtual) and but I had to exclude the actual URL since it was triggering the goals twice.
Issue is that, when I create a event (say a click) in the page, Tag manager is sending that to Analytics but there it is not getting captured since the url is excluded.
Is there any possible way I can track the events in that page without affecting my goals and using a single actual URL?
Note: I cannot stop sending PageView for that particular page as GA script is added to a global Layout file.
If I understand correctly you want to exclude the "physical" url for a pageview in favour of a virtual url, but still want to retain the events that are sent to this physical url.
From the top of my head I'd say create an "advanced" filter, set field A to request url and match the value of the url you want to exclude, set Field B to "hit type" and use "pageview" (you might have to check if that's the proper name, but it should be), and choose "custom field 1" as output field. Set the value for the output to "exclude", and make sure that the checkmarks for "Field A required" and "Field B required" are both checked. Should look something like:
Then instead of using you current exclude by url filter create a filter that excludes based on the value of custom field 1:
That way you only dismiss the pageviews, but keep the event, even if the url is the same for both. Untested, so may require a bit of tweaking, but the principle is sound.
However I don't think this is actually the way to go (it's just cool that you can do stuff like this). I think instead you should overwrite the page path field in your event tags with the path of your respective virtual pageviews. That way you don't need filters, and it makes for better reports.
I have set up Google Tag Manager and 2 data layer variables: one for tracking userid, to be passed to Google Analytics for synchronizing user sessions, and one to track visitor type.
Both variables are assigned values as expected when previewing Google Tag Manager while using Universal Analytics Tag. The UA tag is configured to fire on Window Load (gtm.load) on all pages but when checking in Analytics, no custom variables are being shown under Audience Reports nor any user id specific synch (this is for a new view) is happening. I have tried firing the UA tag on dom ready and page view as well, but no change in result.
My visitorType variable is mapped to corresponding custom dimension index in Analytics, the custom dimension is in active state in GA . The userid has been defined as Field to Set in Tag Manager and value assigned to data layer value. My Google Analytics has userid views enables and I created a new view to be able to see the analytics for user id.
http://i.stack.imgur.com/WDCo3.png
I guess you should first create a dataLayer variable in GTM to tell GTM that the dataLayer variables you are pushing should be mapped with {{uid}} and {{visitorType}} displayed in your IMG.
Example with "uid" :
in the container, go to Variables >> dataLayer Variables
In the Variable name, you should use uid (as mentionned in the IMG), and in the Data Layer Variable Name, you should use exactly the name of the variable pushed into the dataLayer.
I'm tracking multiple domains/subdomains (domain1.com, domain2.com and sub.domain1.com) with Google Tag Manager/universal analytics.
I created a Custom Tag Event (in GTM) that fires on ALL of those pages.
Is there a way to capture the specific page where that event was fired from?
For example, I have an event that fires when a user hovers over a specific <div> element. This occurs on both domain1.com, domain2.com and sub.domain1.com.
When those events fire, can I send the specific domain to GA's event catogory/action/label tags?
some suggestions:
1) You should already be able to break down an event dimension by pages or visa versa (e.g. go to the event report and add pages as 2ndary dimension. Or go to the page you want to see and put event category/action/label as 2ndary dimension). You could also create a segment based on page name. Of course, using the page names may not be useful if you are getting the default relative url (no domain). It is common for people to create a filter that adds domain prefix when spanning multiple domains.
2) Set a custom variable to pop with the domain (or full page name) during the event (or just set it when the visitor goes to the domain and set it as session/visit scope). You can then use this as a breakdown dimension. Or, you can use it to create a segment.
3) Restructure the event hierarchy to incorporate the domain. For example, make the top level (category) be the domain (or full page name). I only suggest this as something you can do but ideally you should go with #1 or #2
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.
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