Google Analytics: Unifying Single Page Application URLs that Contain IDs - google-analytics

We'd like to track behavior flow in our single page application using Google Analytics. We use the hash to route in the application, and we can track the URL within the app with virtual pageviews as described in Google's documentation. However, many of the URLs in the application contain ids, and are considered distinct URLs, despite representing the same page. Thus, we're unable to get accurate behavior flow information in Google Analytics for those pageviews.
For example,
http://example.com/#/dashboards/8a86204a-7b10-4bf5-961b-be16d209f2b0
and
http://example.com/#/dashboards/d8d6a9b5-b6f1-4159-bd6b-622e628f87b2
would be considered distinct pages, when really, we'd like to group these two urls together to determine how users use the dashboard view, rather than how users use a particular dashboard.
Is there a way to unify URLs like this so we can view metrics and behavior flow in aggregate (either in Google Analytics, or in the SPA)?

Completing the answer from #Eike. You can indeed use virtual pageviews to just set the url to '/#/dashboards' using the command
ga('set', 'page', '/#/dashboards'); and then send your pageview. But in my opinion keep the individuality in your data and use a custom dimension to achieve the aggregation you want. Meaning that you should define first a custom dimension that is named for example 'sitePageAggregate'. This dimension will take the value of your website's 'section' url for example 'dashboards' or 'search results' or anything else that might need the aggregation for the behavior flow. This can be done by code in before your pageview hit in each page like this
ga('set', 'dimensionN', 'dashboards');
where N is the custom dimension index. More info on how you can do this here. Now you will just go to your GA interface, Under Behavior -> Site Content -> All pages and just set the secondary dimension as 'sitePageAggregate'. In that way you are retrieving the results you want.

Related

Google Analytics: filtering URI but not events sent together

I need to filter out some URI from Google Analytics (because I send some custom pageviews on these pages instead), but not the events sent together on these pages.
The filter I applied is the following.
Unfortunately, the filter above excludes also all the events sent on the pages included in the Filter Pattern.
How can I filter out the URI but not the events sent on those URI?
Thanks.
The event is tracked at hit level, so filtering the hit on a page also filters the associated event. (I couldn't find a place in the documentation confirming this right now but I'm pretty confident about this).
Instead of the events, you may use custom dimensions or metrics, with a session or user scope (cf. filters). You may want to read more about scopes here, in order to identify which one works for your use case.
Also, please be aware that a view filter is destructive: the filtered information will not be stored, and will never be available in the future. Based on your use case, you may want to take one of these approaches instead:
use segments or filters inside reports instead of view filters.
create an additional view, not containing any filter, so that full dataset is available whenever needed
At the moment, you're using the Filter to remove hits. This means that any hits that match the filter will be lost, including Event and Page View hits.
It sounds like what you require is some kind of search and replace that strips out those custom URIs from the hits that they accompany: so the hits go ahead, but the custom URIs are edited out of them.
Alternatively, you could alter the reporting on those events so that they tell Google Analytics that they take place on a different page.

How can I track visitors’ paths from one page to another with full URLs?

Say I have two pages on a site called “Page 1” and “Page 10”. I'd like to be able to see the paths visitors take to get from “Page 1” to “Page 10” with full URLs intact. Many of the URLs (including those for “Page 1” and “Page 10”) will include query strings that are important.
Is this possible? If so, how?
Try using behavior flow reports. The report basically shows you how visitors click through your website. There are a lot of ways to customize the report, with which you will need to play around to really answer your question. By default, the behavior flow focuses on entry and exit points of visitors, regardless how many times they hit the different subpages in between. However, I'm sure you can set appropriate filters and settings to answer your question.
I use two methods for tracking where people have been on my website:
Track and store the information in my own SQL database. (details below)
Lead Forensics (paid subscription, but you can do a trial).
For tracking and storing my own data, I record unique visitors based upon the IP Address they're connecting from and then have a separate table that records all page views that links back to the unique visitor table.
Lead Forensics data simply allows me to link up those unique visitors with actual companies that have viewed my website.
Doing it yourself means you don't have to rely on Google working for your records to work, and in my experience Google Analytics tends to round numbers so you don't get a true indication of numbers, and also you can remove bots and website trawlers from your data by tracking the user agent string.
As a somewhat ugly hack you could use transaction tracking. If you use the same transaction id multiple times subsequent products will be added to the existing data. So assign an ID at the start of the visits and on each page record a transaction with the current page url as product name (and the ID as transaction id). This will give you the complete path per user (I am frankly not to sure how this is useful - at some point you probably want aggregated data. Plus each transaction and product counts towards your quota for interaction counts, so on a large site you might run over the 10mio hits limit).
you can do it programatically
have a MAP in the backend which stores the userId (assuming u would have given a unique ID at the time of login to each user) with a list of Strings(each string being URL visited by that user)
whenever the user hits another URL from Page 1(and only from page1, check it using JS), send a POST request to backend with the new URL in its data section.
In the backend, check if the URL is of Page 10 and if not, add this URL as a string into the MAP for that corresponding user
Finally, when the user clicks on the Page 10 URL, you know the URLs in the way from Page 1 to Page 10 and so use them.
Though if I consider JS and I have not misunderstood your question, we can get the previous URL from request header information using document.referrer.
Are you trying to do it from 'Google Tag Manager'? I am not sure whether you are trying to trace the URLS in clientside or server side?

Google Analytics segmentation customvar vs uri

I want to be able segment analytics data by company once my customers have logged into my website. Being very new to analytics, it seems like there is a couple of ways I could do this.
Set a visitor level custom variable that would signify the company. For instance, _setCustomVar(1, 'customer', 'ABC Corp', 1)
Pass in a custom Url to my _trackPageview calls whose first segment would signify the company. For instance, _trackPageview('/ABCCorp/the rest of the document path, querystring, etc.')
It seems you can't filter on a custom variable so I could not create a view\profile for each company but I could use Segments and Custom Reports off an 'All Web Site Data' view to do that instead.
Going the custom url route seems to be more flexible since I could either filter or use segments.
Are there any other pitfalls or reasons to suggest using one of these two approaches over the other?
This use case is better suited for custom variables.
Changing the URL will make it more difficult to do things like "How many home page views did I get" or "What do clients usually do after they login".
Also, you can create custom reports based on the information you're passing back and include the custom variable information as the first key. Pretty easy to duplicate GA's current top reports in a custom report using the custom variable as the main dimension.
Agree with Tom that CustomVar is a much better and cleaner solution.
You might want to switch to new Universal Analytics and use Custom Dimenions instead. It's even better and you can set up property filters with Custom Dimenions too, so this should cover all your needs.

Using advanced filters - Google Analytics

A client I am working for has a requirement to use historical data in Google Analytics to present a report that shows them page views on a specific page, but only when refereed to said page from the homepage, basically like in-site ad tracking. I have discovered that I can create reports that are grouped on a user-defined variable, however I need previous data to also be included in this report, and therefore cannot simply define this inside of my Google Analytics call.
I have therefore been experimenting with Advanced filters, in an attempt to populated the user-defined field with a query-string variable. I have attached an image below illustrate my current configuration:
This configuration isn't populating the "User-Defined" field, and therefore not producing the desired results.
Any help would be appriciated.
Any filters you set will only be applied to new data, not historic.
Probably what you are after can be retrieved through the Analytics API (you can use the Query explorer for that).
Try the following:
dimensions: ga:nextPagePath
metrics: ga:uniquePageviews
filters: ga:previousPagePath=~<YOUR STARTING PAGE>;ga:nextPagePath=~page\=
sort: -ga:uniquePageviews
What the query is asking is "Which are the top pages that include 'page=' did users click on from your starting page?"

Google Analytics Interface - Adding onLoad Event to Goals

Hey I'm having some trouble using the Google Analytics interface and wondering if anyone has ever experienced this.
I recently added an onLoad event to track certain pages of a site but I can't seem to understand how to add the Goals to my Analytics account.
Any help would be greatly appreciated!
thank you
Use this information from here and put it into "Goal Type:Event" Section 1
_gaq.push(['_trackEvent', 'category', 'action', 'opt_label', opt_value]);
There is a problem with terminology here since "event" is ambigous - did you add a Javascript onload event handler to your page (which wouldn't be necessary for GA tracking) or do you want to use Google Analytics event tracking (which is was Silas assumed) ?
In any case, Analytics Goal are created in the admin section in your account, under profile settings->goals. There you have to enter a unique name and a type.
Type "Url destination" mean your visitors have reached a particular page (goal url) in your website (either the precise url (match type "exact"), a url that starts with your goal url (head match) or a url that matches a given pattern (regular expression).
If people are supposed to follow a given path before they visit the goal url you can create a funnel by checking the "Use funnel" checkbox and enter the individual urls they have to visit before getting to the goal url. That's useful especially if you have some sort of checkout process - the funnel visualization report will show you how many people exited the process before they reached your goal url and at which url (high exit rate at a given steps means there is a problem and you should optimize this particular page).
In the same way you can create a goal for a google analytics event, only those do not have funnels (an event has more or less by definition only one step).

Resources