Google Analytics Multi-domains Tracking Code - google-analytics

I have the same GA code on 2 domains that I'm trying to track: domain.com and domain.de. Do I need to add setAllowLinker and setDomainName in both domains? Both sites are under the same account/profile but using hostname filter.
(the sites won't link between each other)

If the sites do not link between each other you don't need a special setup - the linker functions maintain sessions between domains (which is not possible with cookies, so the session data is transmitted via Url) and setDomainName sets the cookie domains, which likewise is not necessary in your case.
I do not understand you second question. If you have created a second data view / profile for you com-Domain it starts at 0 visits (pageviews etc) because the view collects data only from the moment it was created, which might be your problem here (plus I think the etiquette at stack overflow suggests to have only one question per Post, so you might edit the seconds question out and put it in a second post).

Related

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?

Cross domain tracking - Report per domain?

I am implementing cross domain tracking for a client. We will be using Universal Analytics with Google Tag Manager.
Let's say the client has three domains: example.com, example.de and example.se. We would like to have a master account that tracks everything, but we would also like to be able to drill down and see a single domains stats. Perhaps this already exists without any customization but I have been unable to find anything on how though.
What I can see there are two ways to go about:
Create a filter that automatically appends the domain to the tracked data. So instead of /about in my view, I would get example.com/about and example.se/about. But how would this work with event tracking? Is it possible to get a report the way the client want's?
Use custom variables and dimensions. This way I could set up a variable for Domain and send in before tracking the data. But will it be sufficient to get the reports wanted?
Appreciate any help.
Thank you,
Bjorn
Hostname ist already tracked, you can set it as second dimension to break down pageviews etc. by domain (works with events, too). However that is really cumbersome and most people follow the route you have outlined in Point 1. (Google suggest that themselves in their filter documentation) - however you'd still need hostname set as second dimension to break down by domain in the events report (or you create custom reports filtered by hostname for events for each domain).
Or you create segments based on hostname (since you can compare up to for segments that would allow you to compare the overall performance and domain performance).
Plus of course you can create additional views filtered by hostname and add the domain name only in the rollup-profile for all domains.
So there are several ways to do this somehow okay-ish, but nothing really better than the solutions you already came up with yourself.

Running GA Experiments across domains w/ Universal Analytics, linker works but Experiment code ignores clientId

Been trying to get this working for a few weeks now. Any help is greatly appreciated.
I have recently upgraded to Universal Analytics and managed to successfully set up cross domain tracking with the autoLinker but I can't get my Analytics Experiment to pass the _ga variable when redirecting the user to a domain part of the experiment.
Setup
Both domains have two trackers, one (t0) which they share [UA-xxxxxxx-5] and one (domainUniqueTracker) which logs to a trackingId unique for that specific domain ([UA-xxxxxxx-1] for main domain and [UA-xxxxxxx-14] for new experimental domain).
Linker is loaded on t0 to enable sharing across domains.
Linker is loaded with an array of domains, including the domain I'm trying to send traffic to via the experiment.
Experiment is created on shared trackingId [UA-xxxxxxx-5].
Context
My company has a product called LIME Pro where we until now have had info about on our company web page. Now, as an experiment we have created a one-page about the system on a separate domain, and they want to see which page (old or new) attracts most leads.
Old product page within company web page (experiment code installed there)
http://www.lundalogik.se/crm-system/lime-pro/
New product page on separate domain (shares trackingId with main domain on tracker t0)
http://www.lime-pro.se
Problem
If I visit www.lundalogik.se and from there click on a normal link to the new, external site (normal anchor link on dummy-page lundalogik.se/experiment/) the clientId is successfully passed along in the URL and the tracker at the external site recognises this and starts using the clientId.
But if I browse to the page where the experiment code is installed, I am redirected to the external site without the clientId being passed along, so the tracker at the external site generates a new clientId.
Thanks and sorry about long post, wanted to explain in as much detail as I could.
The various linker functions in UA add _ga to outgoing links (form, frames etc.). Since the redirect happens in the experiment javascript the client id cannot be added to the url (which in a way seems to be an oversight on Googles part - it seems they did not anticipate your use case, i.e. content experiments across domains).
I have a few untested ideas to contribute, maybe you can build a solution on top of one of them.
1) Before the experiment code fires push the client id to window.document.location.hash. At least in Chrome this does no cause a reload (as far as I can tell from looking at the network tab). Since the hash is now a part of the url it should be sent along when the redirect fires. Then you need a script on the receiving page that checks the hash for a clientID and passes it to analytics if present.
2) Basically the same, only this time with the pushState method (https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history) which should allow you to provide the query parameter without reload.
3) Make the variation page a page within your main domain. Instead of any content put a javascscript there that reads the clientId from the cookie and redirects to the other domain
4) Same as 3, only serverside (don't forget to include the content experiment parameter in the redirect)
As I've said this is basically thinking aloud but it might provide clues toward a solution.
My apologies for only having half an answer but I got orders from above to drop this before I got it fully working. Hopefully it will still be somewhat helpful for someone looking to do the same.
If you do get the receiving part done, please post your code here and I'll update this answer/reward you with the answer.
OK here goes nothing..
The sending side works and adds the clientId to the hash and it is successfully transfered when the experiment does a cross domain redirect.
PAGE WITH EXPERIMENT CODE
Execute this before you run the experiment code.
var z, y, x = document.cookie.split("; ");
for (var i = 0; i < x.length; i++) {
y=x[i].split("=");
if (y[0] == "_ga") window.location.hash = y[1];
}
PAGE ON CROSS DOMAIN
Here is where I never got to before receiving my orders to drop this. But you would do something like:
checking window.location.hash and if it contains a clientId (window.location.hash.substr(0,3) == "#GA")
check for existing cookie
2.1. (exists) split cookie by "; ", find "_ga" and replace it's value with above hash (remove "#" first)
2.2. (doesnt exist) create a new cookie at domain level and set "_ga=(hash-value)"
initiate google analytics tracker which would assume the visitor already had accessed the page before and accept the client-id from the cookie
live long and prosper
So, sorry again for an answer is only partially complete but hopefully someone will benefit from this.
Or at least not assume they are mad like I did when I couldn't get it working :).
If the community would like I will of course remove the "accepted answer" if this is considered bad practice (this is only my second post ever to the SO network).

In Google Analytics, how do I ignore a specific subdomain as a referral? The proper use of _addIgnoredRef

I need help understanding and also instructions on how to properly use "_addIgnoredRef".
First I will explain what type of situation I am in. We have 2 subdomains (each subdomain has it's own webserver/application) that is being used as one website, meaning there are links going back and forth between these two subdomains. For the sake of just using an example, let's say we have "abc.website.com" and "123.website.com". We have links on abc.website.com that links to 123.website.com and vice versa, however they are treated as one website.
Second, we do not develop or change any google anyalytics code to the domain website.com. We only have access to the subdomains, abc.website.com and 123.website.com.
So the issue we are seeing is that Google Analytics is telling us that we have referrals coming from these two subdomains. I understand that it's because we have these two subdomains linking back and forth.
I do understand GA has a command that allows me to IGNORE the referrals by using _addIgnoredRef . However, am I safe to assume that I go to abc.website.com and append this to the GA code,
_gaq.push(['_addIgnoredRef', '123.website.com']);
and vice versa for 123.website.com?
Ultimately we want to not see referrals coming from 123.website.com and abc.website.com, but we don't mind seeing referrals coming from website.com or www.website.com.
If what I have assume is correct, then I must be missing something because that is what I have setup currently. Then my next question would be, do I have this correct?
_gaq.push(['_setDomainName', 'website.com']);
Do I need the trailing period?
You can go on and on about how that having two subdomains as one website isn't a good idea for many reasons but this is what was provided to us when we first started. We will eventually merge them into one website, but for now let's just say it will take awhile and we need to "bandage the situation".
First off, adding _addIgnoreRef will only convert the referral into direct traffic. If this is desired, then yes, you would add:
_gaq.push(['_addIgnoredRef', '123.website.com']); //add to abc.website.com
and
_gaq.push(['_addIgnoredRef', 'abc.website.com']); //add to 123.website.com
The trailing period isn't necessary, just as long as you are consistent across the entire website. According to Google, the trailing period comes more into play when you have multiple layers of subdomains - https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory?csw=1#_gat.GA_Tracker_._setDomainName

Google analytics and dynamic pages

I have a (Symfony based) website. I would LIKE to analyize the site traffic using Google Analytics. My site is divided into several (i.e. N) categories, each of which may have 0 to M sub categories.
Schematically, the taxonomy of the site breaks down into something like this:
N major categories
Each major category may have 0 to M sub categories
further nesting is possible, but I have just kept it simple for the purpose of illustration.
I need to know which sections of the website are genererating more traffic, so that I can concentrate my efforts on those sections. My question is:
Is there anyway to identify the data that is being generated from the different sections of my site?.
Put another way, is there a code or 'tag' that I can generate dynamically (in each page that is being monitored) and pass to GA, so that I can identify which section of the website the traffic came from?
The documentation I found on google about this topic was not very useful (atleast it did not answer this question).
You can pass a uri to _trackPageview that would permit you to log the request in whatever format you'd like, including however your user's requesting the page.
Remove/replace the original call to pageTracker._trackPageview with the following:
pageTracker._trackPageview('/topcategory/subcategory');
You'd just need to plug in the topcategory and subcategory info. If the info is available in the URL you could parse it out using js on the fly.

Resources