Submitted by sgrayban on Tue, 02/08/2011 - 15:11
New style tracking code
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'TRACKING_CODE']);
_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>
Status:
Active
Comments
Submitted by sgrayban on Tue, 02/08/2011 - 15:12 Comment #1
Where the TRACKING_CODE is the Web Property ID
Submitted by JamieCameron on Tue, 02/08/2011 - 15:57 Comment #2
The code to use this new javascript has been written, and we plan to release a new version of the virtualmin-google-analytics plugin that will include it this week ..
Should be out tonight, actually, assuming my Internet keeps working reasonably well.
Submitted by sgrayban on Wed, 02/09/2011 - 02:16 Comment #4
Hmm I'm not seeing the new tracking code after i did the upgrade
Submitted by sgrayban on Wed, 02/09/2011 - 02:31 Comment #5
Hmm you stuck the code in a new place.... before the
</head>
tag... shouldn't be before the</body>
tag ?Submitted by JamieCameron on Wed, 02/09/2011 - 12:19 Comment #6
I just checked the page on analytics.google.com where they tell you the javascript to use, and it says :
Copy the following code, then paste it onto every page you want to track immediately before the closing </head> tag.
Submitted by sgrayban on Wed, 02/09/2011 - 12:36 Comment #7
You are correct... they really changed the code.
Copy the following code, then paste it onto every page you want to track immediately before the closing
</head>
tagSubmitted by JamieCameron on Wed, 02/09/2011 - 12:37 Comment #8
I suspect it would work either way, as the script is executed regardless of where it is on the page.
Submitted by helpmin on Wed, 02/09/2011 - 15:46 Comment #9
Yes, it should work, but the script would be executed "late" and google analytics wouldn't be able to catch users etc that leave the site before the google code is executed (probably especially for slower site :-)
I think this was also the reason why google rewrote the script in the first place.
Submitted by Issues on Wed, 02/23/2011 - 16:21 Comment #10
Automatically closed -- issue fixed for 2 weeks with no activity.
Submitted by bwells on Fri, 03/04/2011 - 12:17 Comment #11
Code has changed again:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '$account']);
_gaq.push(['_setDomainName', '.DOMAIN.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);
})();
If there was an addition so that we could change this on our own that would be the best fit, like setting custom httpd.conf entries in the templates file.
Submitted by sgrayban on Fri, 03/04/2011 - 12:24 Comment #12
So they added
_gaq.push(['_setDomainName', '.DOMAIN.COM']);
Also when you post code here you need to use the <code> tags
Submitted by sgrayban on Fri, 03/04/2011 - 12:27 Comment #13
You can't use the http.conf to add java but maybe they can add a text box to edit the current analytics code.
Submitted by bwells on Fri, 03/04/2011 - 12:28 Comment #14
Yes that is all they added, and sorry about the formatting
Submitted by sgrayban on Fri, 03/04/2011 - 12:32 Comment #15
I don't understand why they need the domain string when it's already assigned when you add a new site. Seems to be a stupid thing to do.
Submitted by bwells on Fri, 03/04/2011 - 12:42 Comment #16
Trust me, I am not understanding it either. Like I stated, if a text box could be added to allow for end users to change the code, that would be great.
Submitted by JamieCameron on Fri, 03/04/2011 - 12:55 Comment #17
I do plan to add an option to allow entering of arbitrary javascript in the next release of the analytics plugin..
Submitted by sgrayban on Fri, 03/04/2011 - 12:57 Comment #18
I just looked at the code and I don't see this change... its still the original code. Where are you finding this new one at ? URL please.
Submitted by sgrayban on Fri, 03/04/2011 - 13:05 Comment #19
When I check the settings to see what code to use for one of my sites I still see the new code I posted...
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-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);
})();
Submitted by bwells on Fri, 03/04/2011 - 13:06 Comment #20
I just posted this on another page. The code that Jamie wrote originally is correct, if you have a single site. The above I sent is for multiple subdomains. Below is the code if you have multiple top level domains:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '$account']);
_gaq.push(['_setDomainName', 'none']);
_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>
Submitted by JamieCameron on Fri, 03/04/2011 - 13:11 Comment #21
Do you have a pointer to some documentation by Google on this?
My understanding was that the domain name could be worked out automatically, since the javascript is on the page that is served from your domain..
Submitted by sgrayban on Fri, 03/04/2011 - 13:14 Comment #22
Umm if I am not mistaken the way the plugin works its using single domain tracking which is the default.
What you are posting is the custom tracking which isn't going to work in the state the plugin is coded.
Since we already have the domain to track custom tracking isn't going to work unless you edit the webpages themselves.
Submitted by bwells on Fri, 03/04/2011 - 13:20 Comment #23
Multiple Domains: http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer...
The last post is correct, but here is the page for sub domains:
http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer...
Submitted by sgrayban on Fri, 03/04/2011 - 13:23 Comment #24
So the code has not changed and what you should be asking for is a feature request. I doubt that would be added as that becomes a very complex plugin using sub.domains....
Frankly its a moot point when google already determines the domain when you add the site.