lynnmcdee Posted March 2, 2015 Share Posted March 2, 2015 Hi, My Google analytic code is out of date and I need to update the code. I have tried to add the code to the main.php file. Google advised to paste it immediately before the closing </head> tag. I have tried this but it is not working. What am I doing wrong?? Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 2, 2015 Share Posted March 2, 2015 The code you were given by Google may not be formatted according to the template engine's requirements. We recommend that you get latest CC5 package (if your store is CC5), and using the Google code from that in your existing files. Otherwise, put: {literal} and {/literal} around the code Google gave you. Quote Link to comment Share on other sites More sharing options...
lynnmcdee Posted March 2, 2015 Author Share Posted March 2, 2015 Hi, Yes, I am using CC5. The code already has {literal} and {/literal} {literal} <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-********', 'auto'); ga('send', 'pageview'); </script> {/literal} Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 2, 2015 Share Posted March 2, 2015 That is the same code present in CC5216 located just above the </head> tag. One slight difference:You have: ga('create', 'UA-********', 'auto'); CubeCart has: ga('create', '{/literal}{$ANALYTICS}{literal}', 'auto'); By having {$ANALYTICS}, the store admin can enter the account number in the admin settings. The above code tracks your visitor's movements, not sales conversions. The sales conversions code is in the content.receipt.php file. Quote Link to comment Share on other sites More sharing options...
lynnmcdee Posted March 3, 2015 Author Share Posted March 3, 2015 Thanks Brian. I am not running the latest version of CC5. I have been putting off upgrading, as I had loads of problems last time. But I think I will have to, as I can't get the tracking code to work. Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 3, 2015 Share Posted March 3, 2015 "I can't get the tracking code to work." Please let us know how you come to the conclusion that the tracking code is not working. Google Analytics is javascript, so the responsibility - assuming the javascript code is correct - is with the browser, with it being affected by any browser add-ons, your personal computer's firewall, etc. Does your browser have a diagnostic mode where you are shown all the page requests and responses (a 'Network' page)? If so, look for your browser to make a request to www.google-analytics.com for the real analytics code, followed by other calls to google. Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 3, 2015 Share Posted March 3, 2015 Here is a fix for versions of CC5 between 5.2.11 and 5.2.14: https://github.com/cubecart/v5.2.14/commit/766c38d04f91d39c7b9e9a4b8391f66d4ac58714 Quote Link to comment Share on other sites More sharing options...
lynnmcdee Posted March 3, 2015 Author Share Posted March 3, 2015 "I can't get the tracking code to work." Please let us know how you come to the conclusion that the tracking code is not working. Google Analytics is javascript, so the responsibility - assuming the javascript code is correct - is with the browser, with it being affected by any browser add-ons, your personal computer's firewall, etc. Does your browser have a diagnostic mode where you are shown all the page requests and responses (a 'Network' page)? If so, look for your browser to make a request to www.google-analytics.com for the real analytics code, followed by other calls to google. When I log into Google Analytic there is a warning message - 'Missing Tracking Code' Here is a fix for versions of CC5 between 5.2.11 and 5.2.14: https://github.com/cubecart/v5.2.14/commit/766c38d04f91d39c7b9e9a4b8391f66d4ac58714 I am currently using version 5.2.5 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.