Google Analytics Changes Script Placement

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
In 1.8 you have the option of including Google Analytics through the admin.  I did this but then decided I could just hard code it into the root master page since this only changes once in blue moon.  So I visited Google to be sure I had the latest script and low and behold they now say to place it just before the closing </head> tag -- not the closing </body> tag!  Has any one else encountered this?  Has it really helped giving their stats a boost?

Google's reasoning makes sense and may help improve tracking.  Also they are very adamant about placing the script right before the </head> assuming you move it from before the closing </body> tag.  This is such a major switch after years of putting analytics at the bottom of the pages.

If I want to place it in the head how can I either hard code the Google Analyics script to just before the closing </head> tag -- the placeholder forces the itself after the Google script so it just sits someplace in the middle of the header section. Or if there really is no performance issue to dynamically feeding the analytics code via the admin, how do I get it to show up just before the </head> tag?

And, while we're talking about the header can we use the Microsoft Ajax cdn? See: http://www.asp.net/ajaxlibrary/cdn.ashx or  http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx

Thanks

BTW --Although I don't use AdSense, it probably has some some changes to script placement too.
13 years ago
Anyone know how to move the Google Analytics code to just before the closing </head> tag as Google now suggests?  Since I still have the 1.8 site running locally, so it's hard to guage the impact on traffic.  Plus, I can't seem to get it to dynamically load just before the closing </head> even if I by pass the admin and just hard code into the root master :(

Thanks in advance for any advice.
13 years ago
renzoz wrote:
they now say to place it just before the closing </head> tag -- not the closing </body> tag!

Google recommends to put the script before the </body> tag:

"Basic installation - Copy and paste the code segment into the bottom of your content, immediately before the </body> tag of each page you are planning to track. If you use a common include or template, you can enter it there."

Source: http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=66983#0.1.1_step4
13 years ago
nopCommerce team | a.m. wrote:
they now say to place it just before the closing </head> tag -- not the closing </body> tag!
Google recommends to put the script before the </body> tag:

"Basic installation - Copy and paste the code segment into the bottom of your content, immediately before the </body> tag of each page you are planning to track. If you use a common include or template, you can enter it there."

Source: http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=66983#0.1.1_step4


Actually, these instructiopns are for old, traditional non-asynchronous scripts -- at the top of this page Google has a highlighted box that states:
_________________________________________
Note: This article is for the traditional (ga.js) version of the tracking code. We recommend you update your tracking code to use the latest (asynchronous) version. For instructions on using the latest version, see this article. http://www.google.com/support/analytics/bin/answer.py?answer=174090
_________________________________________

And, if you go to these new asynchronous it has this at the top of the page:
_________________________________________
BEFORE YOU BEGIN: If you're already tracking your website using an older tracking snippet, first remove the older snippet. You can use a text or HTML editor on the file that contains the snippet and save it if you have customizations you want to add back in later. (Looking for the traditional snippet? See this article.) http://www.google.com/support/analytics/bin/answer.py?answer=174090
_________________________________________

Clearly Google is encouraging evryone to set up the tracking code  with the asynchronous method.  I am in the process of doing this for other Web sites I have.  This brings me back to how to do this easily in nop 1.8.  I have source code and VS.  It should probably be incorporated into the next release too because so many people use Google Analytics.

Thanks!
13 years ago
A store owner will be able to select a Google Analytics script placement (before </head> or </body> tag) in the next release. See changeset http://nopcommerce.codeplex.com/SourceControl/changeset/changes/58622 to get the fix right now
13 years ago
Google want to record who visits your site even before the complete page load, in case if the user exits before. That is the reason for advising using before </head>

But if you use the analytic script after html tag will also work.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.