Google analytics double reporting - javascript

I am trying to determine if my google analytics are being reported twice based on the javascript below in my page. I dont have to have the second script in there to make it work as far as I know, but I am trying to determine if page views/sessions were being recorded twice based off of this configuration. If anyone can provide a test I can do to find this out myself i would appreciate that as well.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXX-3']);
_gaq.push(['_setDomainName', 'mywebsite.com']);
_gaq.push(['_setAllowLinker', true]);
_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>
<script type="text/javascript" async="" src="http://www.google-analytics.com/ga.js"></script>

Related

Google Analytics inpage_linkid script tag ID is undefined

I have the following code in the <head> of my HTML
<script type='text/javascript'>
var _gaq = _gaq || [];
var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
_gaq.push(['_setDomainName', '<%"WEBSITE"%>']);
_gaq.push(['_setAccount', '<%"ANALYTICS_ACCOUNT"%>']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
This automatically creates the Google Analytics code. However, one of the scripts it adds to the page doesn't have an ID.
<script id="undefined" type="text/javascript" async="" src="http://www.google-analytics.com/plugins/ga/inpage_linkid.js" ></script>
I'm wondering if anyone knows of a reason this is happening and how I could prevent it.

Google Analytics, track same website with two different accounts, how?

as the title says, how do I track a website with Google Analystics from two different accounts?
I made some research about this topic and found alot of old posts which were saying that you should include the different tracking codes at each side. But this can't be the best way, right?
Is it possible to do something like this?
Old Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-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>
New Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_setAccount', 'UA-xxxxxxxx-2']);
_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>
Thanks in advance Jack
Yes, its possible without updating any old code. you have to add other account to primary account:
Click Admin at the top of Google Analytic page.
To show three column Account, PROPERTY, VIEW.
Select USER MANAGEMENT from Account, PROPERTY, VIEW base on access permission.
Enter Email address and assign roll.
check your secondary email address website tracking same as primary email address.
You can track the same page on two different GA accounts using this code:
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-12345678-1'], // First account
['_trackPageview'],
['b._setAccount', 'UA-87654321-1'], // Second account
['b._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);
})();
This has always worked for us.

There are 2 google analytics event fired in one page, i want only one analytic to fire in that page

I have two Google analytic s event in one page. I only want one Google analytic event. Is there anyway i can remove one so when i open that page, only one Google analytic can be seen.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-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>
and,
<script type=text/java-script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans','7000004','380194','99.99','7.27','20','Richfield','MN','US']);
_gaq.push(['_addItem','7000004','38361','Power Shovel (38361)','','99.99','1']);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(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 want second one to delete.
Thanks a lot
If I've understood your question correctly, this should be really easy to resolve.
It looks like you've got two identical blocks calling Google Analytics (on the account UA-31277529-1), the first is just the vanilla add-to-the-page code supplied by Google.
The second block includes the same initialization but also pushes a couple of additional pieces of information to Analytics (eCommerce tracking?). Essentially, you've got redundancy in the set-up and page tracking because of that first block.
So, I'm assuming that you want to both:
track page visitors via Analytics;
and track the additional eCommerce attributes you're pushing.
Then, all you need to do is remove the first code block and use only the second one:
<script type=text/java-script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31277529-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans','7000004','380194','99.99','7.27','20','Richfield','MN','US']);
_gaq.push(['_addItem','7000004','38361','Power Shovel (38361)','','99.99','1']);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(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>
This will still track your page views, but will also track your eCommerce objects, which should all occur in one, single 'fire'.

Google Analytics Tracking Code Will Not Fire on "3rd Party" Domain

The tracking code on the site in question, "site2", appears as follows:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_setDomainName', 'site1.com']);
_gaq.push(['_setAllowLinker', true]);
_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>
</body>
</html>
Here is a screenshot of the debugger on that site:
The _setDomainName method on the preceding domain, "site1" has a period before it:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_setDomainName', '.site1.com']);
_gaq.push(['_setAllowLinker', true]);
_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>
While this may or may not prevent cookies from being passed along to the second domain, the tracking code should still at least fire, no? It is important to note that we own both domains. I cannot find any reason that would cause the code not to trigger, except perhaps an error elsewhere on the page. I am using GA Debug to see whether or not the beacon is being sent. It's being sent on site1, but not on site2.
Thanks for the help!
_setDomainName tells the Google Analytics cookie where to store itself. Browsers will not let set a cookie on site1.com from site2.com. Leave .site1.com on you main site and update it to .site2.com on your second.
If you'd like visit data between domains, you have to do one of the following:
Tag the links between the domains using linkByPost etc... Read the google documentation about it here: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite
OR I'd recommend looking into Google Analytics on Steroids as they solve this use case more elegantly: https://github.com/CardinalPath/gas#cross-domain
I don't believe that you need the period before the domain name. According to the google analytics guide you should use the following formatting.
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_setDomainName', 'example-petstore.com']);
_gaq.push(['_trackPageview']);
</script>
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#domainSubDomains

Google Analytics - Download link event tracking

I would like to count my downloads through Google Analytics events. Unfortunately nothing shows up in my statistics.
This is the GA code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_setDomainName', 'example.com']);
_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>
And my link:
Download
Why it is not working?
According to Google Documentations :
<a href="http://www.example.com/files/map.pdf" onClick="javascript: _gaq.push(['_trackPageview', '/downloads/map']);">
To verify that _trackPageview is being called correctly, you can check your Top Content report 24-48 hours after the updated tracking code has been executed. You should be able to see the assigned pagename in your report.

Categories