How to track urls without sessions and encrypted url in google analytics in a decent way? - google-analytics

General setting
I have a website, which uses regular and encrypted urls. Now I want to track the pageviews or all pages the same way.
I have regular URLs like this:
/library.dll?page=page12&arg1=0&arg2=some&session_id=7892734
and special pages like this:
/library.dll?page=specialpage&arg1=0&arg2=some&session_id=7892734&id=page13
aswell as encrypted URLs like this, which are also containing the session id:
/library.dll?page=encrypted&args=gYZEI7lnRAQLzVXdtdbcral8.cOoc6NDtMUGY2yep9wO3JM
So the interesting niformation is always the page, which is in this examples page12, page13 and page14 (where page14 is also part of the encrypted string).
Clarification
I can change the HTML and JS code only. I have no access to the Google Analytics interfaces at all. This will be administrated by multiple customers.
The GA code will be integrated within a template using a customer-specific code and their unique tracking id.
Problem description
I need to track the page argument, because this is basically the interesting part of the url. When tracking other url parameters I cannot accumulate the pageviews for a certain page, because Google Analytics shows them as separate pages.
In addition I don't see any way to track the pageviews with encrypted URLs, because I cannot set a generic name for them unless there is a way to utilize the method ga('send', 'pageview');
Solution idea
I read about overwriting the pageview attributes like this:
ga('send', 'pageview', '/my-overridden-page?id=1');
in the article on page tracking #Google Developers
Utilizing (event) triggers is in my opinion a pretty bad idea.
The question itself
Is there any smarter way to track this information? Is extracting the page-information and overwriting the pageview attributes the best way to do this?
I just started using GA and have kind of no idea how to do this any other way.

You could use filters (custom advanced filters) to rewrite the request url inside the google admin interface (admin->views->filters). This has the advantage that you do not need to change your site/application code.
However using filters will require multi-step-filters with heavy use of regular expressions, and you would have to test this in a "staging" view first (because a wrong filter will permanently mess up your data).
Passing a custom url to the pageview tracking is pretty straightforward and can be tested immediately via the real time view. In my opinion this is indeed the smartest way to do this.

Related

Track links with Event or Query strings with Google Analytics

I am using Google Analytics and would like to see how users interact with my site, mainly what internal links they are clicking and from where.
One approach I've found is to add queries to my links like so ?ref=sidebar or ?ref=featured
Another approach is to use Event Tracking _gaq.push(['_trackEvent', 'Article', 'Click', 'Sidebar']);
I am wondering: Is there any reason to use one approach over the other? I know Event Tracking can be used to capture Javascript events, which queries cannot. But most sites I've seen also uses Event Tracking on their links, instead of simply adding a query string. Why is that?
Query Strings make different unique urls. So if you add query strings to your pages the pages report will show multiple entries for (basically) the same url depending on how people got there, e.g.:
subsite.html
subsite.html?ref=sidebar
subsite.html?ref=featured
each with it's own pageview count and other metrics.
Usually you do not want this. Event tracking is better since it does not blow up the url count (there might be be even better ways, especially if you upgrade to Universal Analytics and use custom dimensions).

Why do my Google Analytics URLs begin with slashes?

When looking at Google Analytics, all reports show URLs that begin with a slash and www: "/www.url.com/page.html."
I've never seen Google report like this. Webmaster Tools is set up correctly. Not sure what else can be set up in Analytics. Any idea?
Current: /www.url.com/page.html
Typical: /page.html
by default GA only reports the relative path and query string of the URL (it strips the protocol and domain. So one of two things must be happening:
1) you have code that is passing a custom page name to the _trackPageview call, adding that "/[domain]".
2) you have a custom filter within the interface setup that is prefixing the page name with "/[domain]"
Adding the domain to the page name is a fairly common thing to do when you have GA code spanning multiple domains, most especially when they are going to a rollup profile, so that you can see which pages are coming from which domain.
So if I had to guess (and this is only a guess, seeing as how I don't have access to your
code or GA interface), someone must have attempted to rebuild the full url to use as the page name instead of just the path+querystring - and then messed up (probably a messup in some regex with the protocol, if I wanted to throw even more guesses at it).
But the 64 thousand dollar question is.. where is it being changed? Like I said.. GA by default does not do this, so someone has added code to do it on your site, or else a filter within the interface.
I would start by looking to see if there are any filters in your interface, since that is the easier thing to determine. If you see no filters relevant to this, then you will have to look on your page code (including any script includes or other javascript code being output). It would be a value passed with _trackPageview so ctrl+f for that.

Fake a subdomain in google analytics

I am currently working on a web app that will be running in an iframe on the webpages of our customers. Now i would like to setup google analytics tracking in a way that i that i can easily distinguish one customer from the other. My plan is to "fake" subdomains, even though it is always the same TLD, so that i can setup a profile for each customer, but still have overall analytics as well.
For example my URL is http://www.domain.com/#/3 where 3 is the customer id. Now i would like to see that in google analytics as 3.domain.com.
Is that possible by doing something like this:
ga('create', 'UA-XXXXXX-1', 'domain.com');
ga('set', 'location', 'http://id.domain.com');
or do i have to go about this in another way? My google analytics knowledge is limited to reading the stats and tracking events and pageviews, so maybe there is a whole different and better way to do this - i am open for suggestions.
Thanks!
It will be much better to use custom variables for this purpose. They give you additional segmentation possibilities on any values and metrics you need, such as customer names or IDs (or both ...)

jquery address and preventing google analytics tracking?

How would I go about preventing the tracking of hash path changes within google analytics while using the jquery address plugin?
original URL:
/?watch
When moving sliders on the page, address bar is appended:
/?watch#/204;276
Within analytics I'm seeing it tracked as unique page views like so:
/?watch/204;276
I'm just wanting it to be tracked as:
/?watch
Help much appreciated.
You could use a custom search and replace filter with a regular expression in the search string.
Before setting up any filters, make a "master" profile in GA that contains unfiltered data. That way if your filter affects your data negatively, you have all your data unfiltered and backed up.
The regular expression I used is ^/\?watch[/0-9;]+ You can test it at RegExPlanet. I didn't put the hash (#) symbol in the regex because, according to your question, GA is not tracking it in the request URI.

Add Analytics to account of someone other than the one who set it up?

I have been requested to get involved with a family member's site.
To date, they have been paying an SEO outfit, which I believe has been feeding them lies and milking them for money.
I can see that all pages in the site have Google Analytics. However, the SEO outfit refuses to let us see the Analytics page, and has always just forwarded them some (presumably doctored) slideshows.
The only tracking service that lists their site is Compete, which shows a number of visitors far from what they are paying for.
I would like to add their site to my own Analytics account. I have ftp access to their server, and permission from the site owners to modify any files I want.
However, I don't want to do anything that might destroy the entire existing history of analytics data, or even that would interfere with the current SEO outfit [until I have something concrete in-hand].
Does anyone know:
Can I add Analytics to my own account when it was originally setup by someone else?
Will there be any negative results of attempting this?
Any other ideas?
Thanks
Edit: Can anyone suggest a better title - I can tell mine is not good?
I've put two Google Analytics tracking codes from different accounts on the same site without issues. It may cause the site to be a tiny bit slower (as it communicates twice with Google) but it'll do nothing that would delete old data or impede collection of new data.
In short, what you're doing sounds like a good first step.
You will not, however, be able to access past data by doing this. You will be able to compare their numbers with the numbers you're getting, though, which should be valuable.
I don't know if you can add the same domain to two different Google Analytics accounts (easy enough to try, though), but you can always add another service's Javascript snippet, e.g. Woopra. Google and Woopra produced very similiar results in my experiments.
You may want to leave their Google Analytics tracking in place while adding your own Google Analytics tracking. In that case, your numbers should be identical to whatever is being tracked by this third party.
You'll need to set up your own account and then add in the creation of your pagetracker object and your own track page view. You don't need to recreate the entire page code. You can do it with two more lines. It would look something like:
var pageTracker =
_gat.getTracker("UA-XXXXXXXX-1"); //EXISTING pageTracker._trackPageView();
var secondTracker =
_gat.getTracker("UA-XXXXXXXX-1"); //YOUR TRACKING ACCOUNT secondTracker._trackPageView();

Resources