Google Analytics eCommerce tracking all shown as 'direct/none' - google-analytics

My eCommerce tracking is working with one exception. All transactions are being grouped as though they came from the same source/medium 'direct/none'.
This is my code;
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-12345678-2', 'auto', 'ecommerceTracker', { 'allowLinker': true });
ga('ecommerceTracker.require', 'linker');
ga('ecommerceTracker.linker:autoLink', ['securedomain.com']);
ga('ecommerceTracker.send', 'pageview');
ga('ecommerceTracker.require', 'ecommerce');
ga('ecommerceTracker.ecommerce:addTransaction', {
id: '123456', // Transaction ID - this is normally generated by your system.
affiliation: '1', // Affiliation or store name
revenue: '99.99', // Grand Total
shipping: '0' , // Shipping cost
tax: '0' }); // Tax.
ga('ecommerceTracker.ecommerce:send');
</script>
I know that at least one of the transactions should of been listed under 'trivago / cpc', as I created this transaction myself.
The only other point to note, is that this transaction process is being carried out across 2 domains.
This is a sample path a user will take;
Visit 3rd party site, in this case Trivago
Click on link, redirecting to our domainname.com
Navigate through our domainname.com pages
Find rooms you want to book
Once you have selected the rooms, navigate to the checkout page
The checkout page is hosted on the domain securedomain.com
From our domainname.com we are redirected to securedomain.com, which contains the same Google Analytics code.
The reservation is saved, and transaction recorded in Google Analytics, but is being shown as 'direct/none'.
One other point to add is that the source domain is http and the destination domain is https. In order to get from the http domain to the https domain, there is a form post.

It may be because the _ga identifier isn't carried through the booking process, so that on the point of conversion the dynamic URL identifier is removed and therefore Google Analytics is referencing the conversion as if it came from a direct source.
I have the same problem and found that this was the case.
See here: https://groups.google.com/forum/#!topic/google-analytics-analyticsjs/kZ8W4iMxAQQ

Related

Double google analytics code at single page may increase page views?

I added two different type of google analytics codes to my site. First:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(["_setAccount", "UA-00000000-1"]);
_gaq.push(["_trackPageview"]);
(function () {
var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Second:
<script type="text/javascript">
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-00000000-1', 'auto');
ga('send', 'pageview');
</script>
when I added these two codes to my site that time my bounce rate is very low, last 30 minutes page view is very high and final report is more page views per day. If i removed these two codes and i added new tracking code means bounce rate is very high, last 30 minutes page view is very low and over all page view also very low. What is happening.? Please help me guys.
Pageview are tracked double if you use the the tracking id (the number that starts with "UA-") for both code versions.
Re. your comment "I couldn't understand the difference between these two codes":
The first set of code is an outdated version of the tracking code. You should not use this anymore, especially since it does not support all current featues of Google Analytics (and will not support features that might be added to GA in the future).
The second set of the is the current version (also called "Universal Analytics), you should use that exclusively. If you still need multiple trackers you need to use named trackers if you want to configure them independently (if you use the same tracking id you will still get double pageviews).
So, use the second version of the code, drop the first one and you should be fine.
Why do you want a pageview twice? That definitly will break google reports because you send useless data.
Pageviews will double (every page is viewed twice).
Bounce rates will decrease drastically (a bounce means a visitor only sees one page = has one pageview and then leaves - but your visitors will have 2 pagesviews, so no bounces)
So only have a tracking code once.

How to track only one domain in google analytics snippet

I´m having trouble figuring out how to track only one specific domain for my project in google analytics. I have a website that runs on two different domains (www.x1.com & www.x2.com)
In the following snippet I´m tracking traffic for both websites (that works) and I´m also trying to track only traffic for x2.com (does not work)
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-XXXXX-1', 'auto');
ga('create', 'UA-XXXXX-2', 'auto', 'x2Tracker');
ga('send', 'pageview');
ga('x2Tracker.send', 'pageview');
I have two different accounts in my Google Analytics website.
How can I track only traffic for my www.x2.com domain (but not both) ?
You can apply a hostname filter to views of a Google Analytics account, so that it rejects traffic from www.x2.com (for example).
Bear in mind though that it believes x2.com and www.x2.com are different hostnames, so you should exclude them both. This is actually why I recommend an exclude filter, because you might have trouble stacking a pair of include filters.
This is done in Admin - View - Filters - New Filter

Upgrading from GA.JS to Analytics.js - replacing _setDomainName, _addIgnoredRef & _trackEvent

I'm currently upgrading my company's website across to analytics.js from ga.js
As I understand, _setDomainName, _addIgnoredRef & _trackEvent are deprecated and need updating.
Can anyone confirm that the below is correct please?
gaq.push(['_setDomainName', 'domain.net']);
This should be replaced with:
cookieDomain: 'domain.net',
legacyCookieDomain: 'domain.net'
_gaq.push( ['_addIgnoredRef', 'www.domain.com']);
This now has to be set in the Analytics admin section?
_gaq.push(['_trackEvent', 'Registration', 'New Account', '<organisation>']);
Should be replaced with:
ga('send', {
hitType: 'event',
eventCategory: ' Registration ',
eventAction: ''New Account ',
eventLabel: '<organisation>'
});
Any help would be gratefully received,
Thanks
How does this final example look?
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-xxxxx', 'domain.net');
ga('send', 'pageview');
ga('send', {
hitType: 'event',
eventCategory: ' Registration ',
eventAction: ''New Account ',
eventLabel: '<organisation>'
});
</script>
You are mostly right except for the cookie domain (at least it'S not obvious from your example that you got it right).
Cookie domain can either be passed as third parameter when you create your tracker:
ga('create', 'UA-XXXXX-Y', 'domain.com');
You can set the parameter to "auto" (IIRC that's the default) and the highest possible level in the domain will be selected as cookie domain (i.e. on subdomain.domain.com auto will set the cookie domain to domain.com).
You can also pass a configuration object with cookieDomain as a property:
ga('create', 'UA-XXXXX-Y', {
'cookieDomain': 'domain.com'
});
which is a useful syntax if you want to set multiple settings at once (you would pass each setting as key/value pair in the configuration object).
As you found out for yourself _addIgnoredRef is now replaced with the referral exclusion list, and your event tracking syntax is fine.

Using Google Analytics within iframes that are used all over the web

My content is being distributed all over the web as an iframe, and I wish to monitor on which pages I get my content viewed on.
I created a Google Analytics property to collect this data - even though GA properties are tied to a domain, and in my case there is no specific domain (as said - it's embedded in pages all over the web).
Because I have many pieces of content that I spread around the web, I hijacked the GA page view mechanism and I report customized information under the page view:
as the URI I provide an internal content ID that makes sense to me
as a page title I use my content's title
It looks like this:
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-XXXXXXXX-XX');
ga('send', 'pageview', {
page: '/<my internal content ID>',
title: '<my internal content name>'
});
</script>
At first it worked brilliantly and I could see for each piece of content - which pages it was viewed on, (under traffic sources in GA - medium=referral, source=hosting page - even for direct browsing... yummy!), but over time I noticed more and more cases in which this information was not available (I got medium=direct, source=not set) - but it only happened in some cases, which I didn't manage to isolate.
Does anyone have an idea of what I'm doing wrong?
I know I'm bending the traditional use-case of GA, but hey - this is what gets us people through the day - right?

Portal Site and Google Analytics Cross-Domain Tracking

I just finished reading about Google Analytics cross-domain linking. All that has done for me is created more questions. I'm hoping to get some help understanding it all.
Our portal site is hosted at http://aq3.processmyquote.com. We create new websites using the first subdirectory as the site name. All secure traffic is directed to https://aq3.processmyquote.com/. For unsecured traffic, we allow our clients to specify an alternate domain name to use for their pages.
We have a single univeral analytics account for the entire site, and views for each client portal. Our issue is that sites which use an alternate domain name are getting tracked as referrals, and we're losing the organic keywords.
Here are some examples: http://www.autoquoter.com, http://www.idriveaffordable.com, http://www.venamex.com
Google's documentation on this states that I should include the autolinker on the main site, and add allowlinker on the secondary sites. How does that work with a web portal? The same tracking code is inserted into each site. Is it ok to just list all the possible domains when creating the tracker?
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-XXXXXX-20', 'auto');
ga('require', 'linker');
ga('linker:autoLink',['www.autoquoter.com',
'www.idriveaffordable.com',
'www.venamex.com']);
ga('send', 'pageview');
This would be added to all of the sites, since they are all pointing to the same web site. The only difference is that the sites are skinned independently. I'm not sure how I would add the destination ga create code or if I even need to.
ga('create', 'UA-XXXXXX-X', 'auto', {
'allowLinker': true
});
Well, I've figured this one out on my own. I'm adding my answer here to help anyone else who may encounter the same issue. In the scenario above, it's important to consider that the purpose of cross-domain tracking is to pass the analytics cookie to the next web site.
Let's say that a user landed on http://www.autoquoter.com and enters a zip code to start the quote wizard. The action of that form needs to be secure so it uses the secure domain name, https://aq3.processmyquote.com/... (the full url is omitted for brevity).
In order to pass the analytics cookie to this url, the url needs to be modified to append a _ga parameter to the query string. This is what the google autoLinker does. It just needs a little help to know which links in the page to modify.
<script type="text/javascript">
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-XXXXXX-20', 'auto', { 'allowLinker': true });
ga('require', 'linker');
ga('linker:autoLink',['aq3.processmyquote.com']);
ga('send', 'pageview');
</script>
Notice that we also can include { 'allowLinker': true }, so that the current page would process an incoming _ga parameter if it exists. On each page, I include the domain names of all possible links in that page. So, if I'm on a secure section of the site, I can only go back to the domain name for that client's portal. In this example, that would be autoquoter's domain name. While we could add all the possible domain names, it's not needed. You only need to include the names that would occur in actual links on that page.
ga('linker:autoLink',['www.autoquoter.com']);
I hope that helps someone. If you have any questions about this, add a comment and I'll try to help.

Resources