I want to install Google Analytics, which file do I need to add it to?
This is a discussion on Google Analytics within the osCommerce 2.2 Discussion forums, part of the osCommerce 2.2 Forums category; I want to install Google Analytics, which file do I need to add it to?...
I want to install Google Analytics, which file do I need to add it to?
/templates/yourtemplatename/main_page.tpl.php
so endith the lesson
<think>sometimes I just sit's and thinks</think>
"Here you are with a hand full of holes, a thumb up your ass, and a big grin to pass the time of day with." - TWB
Just had to do this, and the search function saved me some time.
The contrib I installed was the following:
osCommerce: osCommerce Google Analytics module
You need to make 3 changes on /templates/yourtemplatename/main_page.tpl.php :
Find your stylesheets, which on my template are like this:
Paste the following code AFTER it, replacing UA-XXXXXX-X with your google analytics account:Code:<link rel="stylesheet" type="text/css" href="<?php echo (bts_select('stylesheet','stylesheet.css')); // BTSv1.5 ?>"> <link rel="stylesheet" type="text/css" href="<?php echo (bts_select('stylesheet','print.css')); // BTSv1.5 ?>" media="print">
Find your body tag:Code:<?php // osCoders.biz - Analystics - start /* Conditional code added thank to rrodkey and bfcase IMPORTANT -- IMPORTANT - IMPORTANT You'll need to update the "xxxx-x" in the samples (twice) above with your own Google Analytics account and profile number. To find this number you can access your personalized tracking code in its entirety by clicking Check Status in the Analytics Settings page of your Analytics account. */ if ($request_type == 'SSL') { ?> <script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct="UA-XXXXXX-X"; urchinTracker(); </script> <?php } else { ?> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct="UA-XXXXXX-X"; urchinTracker(); </script> <? } // osCoders.biz - Analistics - end ?>
Replace with:Code:<body>
On my template I have no parameters on my <body>, if you have them, keep them and place the onLoad="javascript:__utmSetTrans()" at the end.Code:</head> // osCoders.biz - Analistics - start // The onLoad="java script:__utmSetTrans()" from the <body ... > tag // was added for the Google Analytics contribution // osCoders.biz - Analistics - end <body onLoad="javascript:__utmSetTrans()">
And at the end, find the /body tag:
And place right BEFORE it the following code:Code:</body>
Last, you need to upload the included file to /includes/modules/analytics/analytics.phpCode:<?php // osCoders.biz - Analystics - start include(DIR_WS_MODULES . 'analytics/analytics.php'); // osCoders.biz - Analistics - end ?>
Hopefully this is all that needs to be done, my Google Analytics account has checked my installation and said it is ok, and that it is gathering information and I will have my first reports no later than 24h from now.
Well I am followed your directions I hope it works in 24 hrs too I'll post if it worked for me
i get a string at the bottom of my screen after installing this... any idea what that is?
"pageTracker._addTrans( "460"," ","2700.00","0.00","0.00","Houston","Texas","U SA" ); pageTracker._addItem( "460","1167","Sharp Dial Microwave R-21LCF","Microwave Ovens","249.00","12"); pageTracker._trackTrans(); "
So, what is "mine", and what it won't pick up?
As far as I was aware this was supposed to work just fine in the secure pages... except it isn't.PHP Code:<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>
ie it works just fine and dandy on http pages and they show up in my analytics but none of the pages in https(ie past /checkout_shipping.php) show up..
this means my goals aren't being tracked
I just did some more looking into it and it seems that it tracks all the way to /checkout_confirmation.php and then gets lost between there and my /checkout_success.php
any idea why it's not recording /checkout_success.php?
No clue, sorry. I still use the old google analytics code (urchin) and I do not use SSL on my web page (just for CC transactions, and that is handled by me)
Bookmarks