PDA

View Full Version : Google Analytics



deaniodice
09-13-2007, 02:23 PM
I want to install Google Analytics, which file do I need to add it to?

met00
09-14-2007, 02:19 AM
/templates/yourtemplatename/main_page.tpl.php

MindTwist
10-22-2007, 10:57 AM
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 (http://www.oscommerce.com/community/contributions,3756)

You need to make 3 changes on /templates/yourtemplatename/main_page.tpl.php :

Find your stylesheets, which on my template are like this:


<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">Paste the following code AFTER it, replacing UA-XXXXXX-X with your google analytics account:


<?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
?>Find your body tag:


<body>Replace with:


</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()">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.

And at the end, find the /body tag:


</body>And place right BEFORE it the following code:


<?php
// osCoders.biz - Analystics - start
include(DIR_WS_MODULES . 'analytics/analytics.php');
// osCoders.biz - Analistics - end
?>Last, you need to upload the included file to /includes/modules/analytics/analytics.php

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.

Pr0ject
06-07-2008, 01:00 PM
Well I am followed your directions I hope it works in 24 hrs too I'll post if it worked for me

Pr0ject
06-07-2008, 01:24 PM
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","USA" ); pageTracker._addItem( "460","1167","Sharp Dial Microwave R-21LCF","Microwave Ovens","249.00","12"); pageTracker._trackTrans(); "

tcshadow
06-23-2008, 12:54 PM
/templates/yourtemplatename/main_page.tpl.php

I put mine in this file and it won't pick up my checkout_success.php


any ideas why?

Oh I'm using the new code btw not urchin

MindTwist
06-23-2008, 03:05 PM
So, what is "mine", and what it won't pick up?

tcshadow
06-23-2008, 03:16 PM
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("&#37;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>As far as I was aware this was supposed to work just fine in the secure pages... except it isn't.

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

tcshadow
06-23-2008, 05:11 PM
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?

MindTwist
06-24-2008, 12:59 AM
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)

tcshadow
06-24-2008, 01:08 AM
yeah I've rolled back to Urchin for the time being

KateyJo
11-10-2008, 12:41 PM
Just from a little experience make sure you have checked that your account is an ecommerce account in your Google Analytics account profile. If it isn't you won't have the right code for tracking https pages.
We are just starting to add this to our site.
I am know some HTML and I am not the programmer that puts the code into the site however I do set up the account profile, the goals and the filters so am busy learning all I can.
I do want to use the ga.js code for Google Analytics also just because it is new and I don't know how much longer the free urchin will be supported.
Just my thoughts.
Thanks for sharing your information.