Last week we deployed another successful Magento ecommerce website. To track the visitors we signed up for a free Google Analytics account, and then plugged their tracking code into the admin section of the Magento administrator area. When we applied the API, the site quickly confirmed that the tracking code was in place through the Google Analytics dashboard. We then waited 48 hours, and then logged in to see how many visitors hit the site. Turns out that none of the visitors were being tracked! Using the error console within Firefox we reloaded the page, and found the problem instantly. Turns out the Magento coders totally messed up when creating their Google Analytics API. Take a look for yourself, here's the JavaScript they used: (function() {
This is how it should read: var _gaq = _gaq || []; As you can see the Magento coders have it all out of order, and forgot the most important line of code that created the “_gaq” object: var _gaq = _gaq || []; We can only assume that this API is broken on all Magento builds! To fix this, remove the tracking code from the Magento Google API in the admin area, then use the JavaScript given to you by Google Analytics, and place it in the footer of your website. Whala! Your site is now tracking visitors appropriately with no errors in the error console.
Comments (3)By Frans Dijksman posted on Tuesday, June 15, 2010 @ 3:43 AMI faced the same problem for one of our clients. Because Google 's advise to place the script just above the tag it's just as simple but better to use design in the system config of MG. This will place the script in the right spot.By J.T. posted on Sunday, September 5, 2010 @ 11:00 AMI run a number of Magento shops off one installation. I used to have one AdWords account, linked ot one Analytics account to track them all.We recently started separating the AdWords and Analytics accounts to keep stuff more organised. As that means stopping one Analytics account's tracking and starting a fresh on a new one, I opted to track to both the new account as well as the legacy account, so that one keeps rolling on nicely, including historic data. Here's how to do it: http://www.lunametrics.com/blog/2009/02/26/pitfalls-tracking-multiple-accounts-ga However, Magento's native Analytics support of course only allows for one Account ID. So, like you, I figured I'd just use the footer code textarea in design. But when I look at the source of any of my current pages, generated with the native Analytics code, Magento renders the SEO URL: pageTracker._trackPageview("/products/masks/nasal-pillow-masks.html"); What I'm no apprehensive about, by plonking the standard (new) Analytics code in the footer manually, is that it just shows: _gaq.push(['_trackPageview']); Without the full page URL. I know this makes a big difference in Woopra, mainly with URL paramters so I'm weary of doing this now this way. Can either of you please report back on this, whether it has affected your content URL reporting? By Rap Music posted on Wednesday, July 20, 2011 @ 10:58 PMI'm pretty sure Magento fixed this error with their last update. Took them long enough to catch on! This is still excellent for those of you who are running older versions since its almost impossible to upgrade without crashing your entire store. lol |
|




