I have tracking code A on the main site www.example.com and tracking code B on www.example.com/blog which is a wordpress.com based blog (the site itself is plain PHP).
Not surprisingly, traffic from the blog is not shown on the main site and visa versa.
I would like to use tracking code A on the blog as well to create a "roll-up" profile while maintaining the profile I currently have with tracking code B.
I thought that the right way to do it is using the following code:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['t2._setAccount', 'UA-XXXXXX-2']);
_gaq.push(['t2._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);
})();
but I read here:
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=640080c650f67bd1&hl=en
that it causes a multiplication in visitor numbers and such.
What is the correct way to do this?
Should I explicitly specify the domain and use the _setAllowLinker() method as described in the linked post above despite the fact that it's the same domain?
Any help will be much appreciated.
Thanks,
Alexander
P.S
I read Google Analytics - async tracking with two accounts but I still don't have a definite answer.
The easiest way to achieve the results you're looking for is to use a single account/profile ID site wide and use profile filters to create a 'Blog Traffic Only' profile.
Sitewide you would call:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-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);
})();
Then, log in to Google Analytics, select your account (if you have more than one), add a new profile (for an existing domain) under the UA-XXXXXX-1 profile number, and call label it 'Blog Traffic'.
Once you create the profile, click to 'Edit' the profile you just created. Scroll to 'Filters Applied to Profile' and click 'Add Filter'. Google Analytics provides a pre-defined filter for traffic to a subdirectory (include only traffic to the subdirectories that are equal to '^/blog.*' or just '/blog').
Now, you'll have a profile that includes all traffic to your site and a second profile that includes traffic only to the blog subdirectory.
More information on using data filters:
http://www.google.com/support/analytics/bin/answer.py?answer=55496
Related
I have a webshop where users come from many different other sites and newsletters. To track where the people came from, we use campaigns in Google Analytics.
Now we are implementing our own external payment site.
After a user places an order, they will be redirected to our payment site. After a succesfull payment, they should be redirected back to the original site. On the original site the ecommerce values will be fired into Google Analytics.
When I do this like I described above, I lost the campaign when insterting the ecommerce data. How do I make sure this information isn't lost?
[edit]
I found adding 'utm_nooverride' should to the trick. However, I can't find it clearly in the Google Analytics documentation
To solve the above:
On both sites (yes, the payment site should have a GA too), you need to set _setAllowLinker to true, and the _setDomainName to 'none'.
IE:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-YY']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setDomainName', 'none']);
(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>
I'm setting up google analytis on my webpage using the standard script:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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>
If I include this site on my UAT page (e.g. http://uatsite.com/) will google track any activity or will it only track activity on my main site (e.g. http://production-site.com).
thxs
The domain (or, as GA likes to call it, hostname) from which Google Analytics receives its info doesn't matter and really it's up to the client to define it (and is very much exploited, see this for just one example).
If you don't want to track activity on your UAT site, you can create a Hostname filter to prevent the data from being recorded. This filter can be of include type so that only your production site registers or exclude type so it excludes only your UAT site.
Alternatively, you can modify your analytics code to not track on the UAT site:
if (!/uatsite/.test(window.location.hostname)) _gaq.push(['_trackPageview']);
This will only collect analytics for the url you configured. This will not collect from any other domain.
I am implementing Google Analytics for a customer that has part of their site on a subdomain on another SSL encrypted site. For example, let's say that their URL is http://www.first-site.com and they have a contact form located at https:// www.second-site.com/first-site/. Also, several other sites that run Google Analytics have part of their site on different subdomains of www.second-site.com.
(Current code for both pages in both domains is listed below)
The Analytics is running and it is tracking both domains and the cookie information is being passed in the URL from one domain to the other, however when I look at the cookie, the visitor ID changes when I go from one to the other. Is this supposed to happen?
Also, the Real Time Analytics report shows a new visitor when I go from one domain to the other. Does this mean that the cross domain code isn't working? I thought that the visitorID in the cookie would be the same from domain to domain.
Any help would be greatly appreciated and any tips for testing the cross domain analytics would be appreciated, too.
Tracking code for http://www.first-site.com: (actual UA number has been replaced)
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_setDomainName', 'first-site.com']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowHash', false]);
(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>
Code for https:// www.second-site.com/first-site/ :
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_setCookiePath', '/first-site/']);
_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>
Here is an example URL from a linked page: https:// www.second-site.com/first-site/apply.htm?_utma=226662157.1705427553.1330793721.1330793721.1330802012.2&_utmb=226662157.1.10.1330802012&_utmc=226662157&_utmx=-&_utmz=226662157.1330793721.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)&_utmv=-&__utmk=195995183
You need _gaq.push(['_setAllowLinker', true]) on the second site as well.
Also make sure that the _trackPageview comes after all other calls.
If you do that you should start to see the visitor the visitorId being the same.
Also note that not all __utma cookie needs to be the same. You just need to check the second number after the first dot. If that is the same than it's probably working. The __utmz cookie also should have the same referrals.
Note that you don't need _setAllowHash anymore. It's deprecated now. And you probably don't need _setCookiePath, unless you have a very good reason to that, and the only good reason is if you have other cookies on second domain that you want to isolate.
I want to track a large website as a whole with several 'normal'pages and several pages containing i-frames. The framed pages' sources are at different domains.
How would I go about in making it work in such a way that all the pages (including the i-framed pages) are tracked in the correct way, even allowing in-page analytics on them?
Here's how far I got: Your comments, please?
1 normal pages should have the normal tracking code.
2 The pages containing i-frames AND the framed pages inside the i-frame should have the adjusted multi-domain tracking code:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-xx']);
_gaq.push(['_setDomainName', '.THIS_IS_THE_SUBPAGE_URL_CONTAINING_I-FRAME']);
_gaq.push(['_trackPageview']);
_gaq.push(function() {
var pageTracker = _gat._getTrackerByName();
var iframe = document.getElementById('THIS_IS_THE_I-FRAME_ID');
iframe.src = pageTracker._getLinkerUrl('THIS_IS_THE_FRAMED_PAGE_URL');
});
(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);
})();
Question:
Am I going about this in the right way? Do the frames need some sort of Javascript cookie transfer? What about P3P policy, does this need to be added?
I have portal which behaves like multiple portal.
The portal code base is same but for all sites but content is based on which url or domain you came across.
Currently i am able to track my domain
example.com
and also subdomains like
a.example.com, b.example.com
. But i want to also track
anotherexample.com
which also point to same domain. How can I do?
Any suggestions?
multiple url pointed to same code base. It does not matter. The only matter is the url above and the tracking code in site is matching or not. So you have to take google access code from database which just write in address bar.
Codes:
<!-- Google Analytics -->
<script type="text/javascript">
var accountNameFromDB = ...Some Operations...
var domainNameFromDB = ...Some Operations...
var _gaq = _gaq || [];
_gaq.push(['_setAccount', accountNameFromDB]);
_gaq.push(['_setDomainName', domainNameFromDB]);
_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>
Just take accountNameFromDB and domainNameFromDB variables dynmically.
Add this code head of master page(or main template) or add every page.