Jump to content
osCoders

Google Analytics module

Recommended Posts

the top part is too high: it must be just before the </head> tag, yours is before the <head> tag!

 

the bottom part is fine

Edited by pixclinic

Share this post


Link to post
Share on other sites
the top part is too high: it must be just before the </head> tag, yours is before the <head> tag!

 

the bottom part is fine

 

 

Thanks pixclinic :thumbsup:

Share this post


Link to post
Share on other sites

Hi,

WORKS GREAT.

 

Thanks to all who wrote this contrib and contributed to this wonderful thread.

It was a PAIN to run through the 23 pages but worth it. Mine appears to be working perfectly and the first time around. :-)

 

Summary of tidbits in the 23 pages of the thread so you don't have to find them.

Thousands issue:

For the thousands issue (, vs .) for those of us in countries where
','
is the decimal separator, one solution is posted several times (
,
) and a different one by flom (also as a contrib). I adopted the first one. Steve explains it best.

SSL vs NON SSL :

I used
. Thanks again to Steve Dallas !

HEAD ? NOT IN THE HEAD ?

I will add to the in the head-not in the head controversy but stating
I did not put the urchin in the head.
I am very lazy and
already
had the urchin code in my footer. My e-commerce €€ stuff
is
showing up like its supposed to, as well as the objectives (G's). So far so good.

 

This puts me in the same camp as
, despite
(a site I very much admire btw.)

and is some sort of a follow up to
,
and
(where I never found his final answer.)

 

This means that I only made 2 changes to catalog/checkout_success.php:

1.

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onLoad="java script:__utmSetTrans()">

2. added right before the </body>

<?php 
// osCoders.biz - Analytics - start 
include(DIR_WS_MODULES . 'analytics/analytics.php'); 
// osCoders.biz - Analytics - end
?>

My purchase conversion code is above it and the require footer above that.

FOOTER

in catalog/includes/footer.php all the way at the bottom of the file (last item) is:

<!-- Steve Dallas shorter script for ssl test http://forums.oscommerce.com/index.php?s=&showtopic=180940&view=findpost&p=914914 -->
<script src="<?php echo (($request_type =='SSL') ? 'https://ssl' : 'http://www')?>.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct="UA-XXXXXX-X";
urchinTracker();
</script>

 

I might say that there is a performance hit for having the code on every page tho'.

Thanks to all,

-i.

Edited by IndiaStarker

*** Je suis plus souvent sur le forum français ***

ms2fr, Header Tags 2.5.5b, Order logging before payment, Better PayPal Description perso, Free shipping per product, Must agree to terms, Country State Selector, World Zones, Visible countries, Store Pick Up, several shipping modules, Personal Invoice Number, 'On the Fly' Auto Thumbnailer using GD Library, More_Pics_6 for 2.2 ms2, Ultimate SEO URLs 2-2.1d/e,Virement Bancaire, Estimated Shipping 1.5, xml_guide, SP+,Step By Step 1.8, Order Editor 2.6.3, Google Analytics, Dynamic Sitemap 2.0, OSC-Expeditor, Recover Cart Sales, Links Manager 1.15

local : linux 2.6 Fedora Core 3, server : APACHE 2.0.54, MySQL 4.1.18, php : 4.4.0 (on strike refuse to update)

remote : IcoOpenBSD 4.x, server : IcodiaSecureHttpd, MySQL 4.1.24, php : 4.4.9

 

You never get a second chance to make a first impression.

Share this post


Link to post
Share on other sites

Hi everyone

 

I would like you input on the referral sources that you can see in

 

E-Commerce Analysis > Revenue Sources > Referring Sources

 

I never saw anything else than my own domain (direct) [none]

 

What about yours?

 

Thanks!

Share this post


Link to post
Share on other sites
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onLoad="java script:__utmSetTrans()">

As others have pointed out, there is no space in javascript but the forum software seems to place one there.

Edited by IndiaStarker

*** Je suis plus souvent sur le forum français ***

ms2fr, Header Tags 2.5.5b, Order logging before payment, Better PayPal Description perso, Free shipping per product, Must agree to terms, Country State Selector, World Zones, Visible countries, Store Pick Up, several shipping modules, Personal Invoice Number, 'On the Fly' Auto Thumbnailer using GD Library, More_Pics_6 for 2.2 ms2, Ultimate SEO URLs 2-2.1d/e,Virement Bancaire, Estimated Shipping 1.5, xml_guide, SP+,Step By Step 1.8, Order Editor 2.6.3, Google Analytics, Dynamic Sitemap 2.0, OSC-Expeditor, Recover Cart Sales, Links Manager 1.15

local : linux 2.6 Fedora Core 3, server : APACHE 2.0.54, MySQL 4.1.18, php : 4.4.0 (on strike refuse to update)

remote : IcoOpenBSD 4.x, server : IcodiaSecureHttpd, MySQL 4.1.24, php : 4.4.9

 

You never get a second chance to make a first impression.

Share this post


Link to post
Share on other sites
Hi everyone

I would like you input on the referral sources that you can see in

E-Commerce Analysis > Revenue Sources > Referring Sources

...

Hi pixclinic.

I see google[organic] and google[cpc]

I think this tool is very cool.

-i.


*** Je suis plus souvent sur le forum français ***

ms2fr, Header Tags 2.5.5b, Order logging before payment, Better PayPal Description perso, Free shipping per product, Must agree to terms, Country State Selector, World Zones, Visible countries, Store Pick Up, several shipping modules, Personal Invoice Number, 'On the Fly' Auto Thumbnailer using GD Library, More_Pics_6 for 2.2 ms2, Ultimate SEO URLs 2-2.1d/e,Virement Bancaire, Estimated Shipping 1.5, xml_guide, SP+,Step By Step 1.8, Order Editor 2.6.3, Google Analytics, Dynamic Sitemap 2.0, OSC-Expeditor, Recover Cart Sales, Links Manager 1.15

local : linux 2.6 Fedora Core 3, server : APACHE 2.0.54, MySQL 4.1.18, php : 4.4.0 (on strike refuse to update)

remote : IcoOpenBSD 4.x, server : IcodiaSecureHttpd, MySQL 4.1.24, php : 4.4.9

 

You never get a second chance to make a first impression.

Share this post


Link to post
Share on other sites

What about correlations ? I don't understand this part.

 

In (what must be in English) Product Merchandising, if I select

- Corrélation produit/mot clé (Correlation product / key word)

 

I only see Products.

I don't see any key words anywhere. Tutorial welcome :-)

-i.

Edited by IndiaStarker

*** Je suis plus souvent sur le forum français ***

ms2fr, Header Tags 2.5.5b, Order logging before payment, Better PayPal Description perso, Free shipping per product, Must agree to terms, Country State Selector, World Zones, Visible countries, Store Pick Up, several shipping modules, Personal Invoice Number, 'On the Fly' Auto Thumbnailer using GD Library, More_Pics_6 for 2.2 ms2, Ultimate SEO URLs 2-2.1d/e,Virement Bancaire, Estimated Shipping 1.5, xml_guide, SP+,Step By Step 1.8, Order Editor 2.6.3, Google Analytics, Dynamic Sitemap 2.0, OSC-Expeditor, Recover Cart Sales, Links Manager 1.15

local : linux 2.6 Fedora Core 3, server : APACHE 2.0.54, MySQL 4.1.18, php : 4.4.0 (on strike refuse to update)

remote : IcoOpenBSD 4.x, server : IcodiaSecureHttpd, MySQL 4.1.24, php : 4.4.9

 

You never get a second chance to make a first impression.

Share this post


Link to post
Share on other sites
What about correlations ? I don't understand this part.

-i.

OK I answer my own question. Actually the correlations can be seen by clicking on the + just to the left of the listed items.


*** Je suis plus souvent sur le forum français ***

ms2fr, Header Tags 2.5.5b, Order logging before payment, Better PayPal Description perso, Free shipping per product, Must agree to terms, Country State Selector, World Zones, Visible countries, Store Pick Up, several shipping modules, Personal Invoice Number, 'On the Fly' Auto Thumbnailer using GD Library, More_Pics_6 for 2.2 ms2, Ultimate SEO URLs 2-2.1d/e,Virement Bancaire, Estimated Shipping 1.5, xml_guide, SP+,Step By Step 1.8, Order Editor 2.6.3, Google Analytics, Dynamic Sitemap 2.0, OSC-Expeditor, Recover Cart Sales, Links Manager 1.15

local : linux 2.6 Fedora Core 3, server : APACHE 2.0.54, MySQL 4.1.18, php : 4.4.0 (on strike refuse to update)

remote : IcoOpenBSD 4.x, server : IcodiaSecureHttpd, MySQL 4.1.24, php : 4.4.9

 

You never get a second chance to make a first impression.

Share this post


Link to post
Share on other sites

HELP :'( Not Getting any data in Analytics on Google..

 

 

I have the code installed and the analytics section of my Google account reports that is recieving data , but no data appears in any report.

 

I have my checkout_success page as the conversion goal and the code in place as below -

 

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<?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-xxxxx-x";
			   urchinTracker();
			 </script>
			<?php
			} else {
			?>
			 <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
			 </script>
			   <script type="text/javascript">
			    _uacct="UA-xxxxx-x";
			    urchinTracker();
			 </script>
			<?
			}
			// osCoders.biz - Analistics - end
			?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onLoad="java script:__utmSetTrans()">
<!-- header //-->

 

 

and at the end .....

 

<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
<?php 
// osCoders.biz - Analystics - start 
	include(DIR_WS_MODULES . 'analytics/analytics.php'); 
// osCoders.biz - Analistics - end
?>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

On succesful checkout a view source shows the transaction , but no data is being sent to google and nothing appears in my reports.

Share this post


Link to post
Share on other sites

Hey, I don't have STS installed on my OsC, but I'd like to still use the advanced code to track the product/customer info. Can someone show me how to add this without having to use STS?

Edited by knicholes

Share this post


Link to post
Share on other sites
Does someone has an workaround to install the contrib on the new sts version?

 

Not sure if this helps but it works for me using STS 4.4.

 

In your template just below

 

<!--$headcontent-->

 

<?php if ( $_SERVER["SERVER_PORT"] == '443' ) { ?>
<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct="UA-xxxxx-x";
urchinTracker();
</script>
<?php
} else {
?>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct="UA-xxxxx-x";
urchinTracker();
</script>
<? } ?>

 

The only difference from oscoders being the server port instead of request type to get it to return the right Google url depending on connection type.

 

HTH,

Iggy


Everything's funny but nothing's a joke...

Share this post


Link to post
Share on other sites

Thanks much, you saved me 23 pages of reading and its working great!

 

Hi,

WORKS GREAT.

 

Thanks to all who wrote this contrib and contributed to this wonderful thread.

It was a PAIN to run through the 23 pages but worth it. Mine appears to be working perfectly and the first time around. :-)

 

Summary of tidbits in the 23 pages of the thread so you don't have to find them.

Thousands issue:

For the thousands issue (, vs .) for those of us in countries where
','
is the decimal separator, one solution is posted several times (
,
) and a different one by flom (also as a contrib). I adopted the first one. Steve explains it best.

SSL vs NON SSL :

I used
. Thanks again to Steve Dallas !

HEAD ? NOT IN THE HEAD ?

I will add to the in the head-not in the head controversy but stating
I did not put the urchin in the head.
I am very lazy and
already
had the urchin code in my footer. My e-commerce €€ stuff
is
showing up like its supposed to, as well as the objectives (G's). So far so good.

 

This puts me in the same camp as
, despite
(a site I very much admire btw.)

and is some sort of a follow up to
,
and
(where I never found his final answer.)

 

This means that I only made 2 changes to catalog/checkout_success.php:

1.

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onLoad="java script:__utmSetTrans()">

2. added right before the </body>

<?php 
// osCoders.biz - Analytics - start 
include(DIR_WS_MODULES . 'analytics/analytics.php'); 
// osCoders.biz - Analytics - end
?>

My purchase conversion code is above it and the require footer above that.

FOOTER

in catalog/includes/footer.php all the way at the bottom of the file (last item) is:

<!-- Steve Dallas shorter script for ssl test http://forums.oscommerce.com/index.php?s=&showtopic=180940&view=findpost&p=914914 -->
<script src="<?php echo (($request_type =='SSL') ? 'https://ssl' : 'http://www')?>.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct="UA-XXXXXX-X";
urchinTracker();
</script>

 

I might say that there is a performance hit for having the code on every page tho'.

Thanks to all,

-i.

Share this post


Link to post
Share on other sites

hmmm, I still did not get it!

 

Besides the modification on the shipping page, do I really have to add the google code to each page seperately?? So it is not possible to add the code to the footer.php or the header.php??

 

thanks a lot!

Andreas

Share this post


Link to post
Share on other sites

Hi,

 

I'm using this with the PayPal IPN handler and have searched through the forums but cannot find a solution, basically whenever someone orders through PayPal they are followed upto the checkout page but then lost so within the e-commerce reports of Google we're loosing a values. It does however work fine with WorldPay.

 

Any ideas would be gratefully received.

 

Tim

Share this post


Link to post
Share on other sites

first of all the script works great for me

but I'm using next to the google analytics part the normal standart

conversation tracking code to see the sells on a keyword base - so I can see

the keywords with the most sells.

 

The normal standant conversation tracking code only gives me the number of sells

(var google_conversion_value = 1) but not the total value.

 

The code looks like this:

 

<!-- body_eof //-->


<!-- Google Code for Purchase Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = xxxxxxxxxx;
var google_conversion_language = "de";
var google_conversion_format = "2";
var google_conversion_color = "CCCCCC";
[size=3][b]if (1) {
 var google_conversion_value = 1;
}
var google_conversion_label = "Purchase";[/b][/size]//-->
</script>
<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0 src="http://www.googleadservices.com/pagead/conversion/xxxxxxxxxx/[size=3][b]?value=1[/b]&[/size]label=Purchase&script=0">
</noscript>


<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>


<?php 
// osCoders.biz - Analystics - start 
include(DIR_WS_MODULES . 'analytics/analytics.php'); 
// osCoders.biz - Analistics - end
?>



</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

the sample code from google with the values look like this - I try searching the analytics.php

to get something but I doesn't find the right part.

 

<!-- Google Code for Purchase Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = 1234567890;
var google_conversion_language = "en_US";
var google_conversion_format = "1";
var google_conversion_color = "666666";
[size=3][b]if (<? echo $totalValue ?>) {
var google_conversion_value = <? echo $totalValue ?>
}[/b][/size]
var google_conversion_label = "Kauf";
//-->
</script>
<script language="JavaScript"
src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0
src="http://www.googleadservices.com/pagead/conversion/1234567890
/[size=3][b]?value=<? echo $totalValue ?>[/b][/size]&label=Purchase&script=0">
</noscript>
</body>

 

hope you understand my english.

 

greetings from germany

 

mikepmm

Share this post


Link to post
Share on other sites
The normal standant conversation tracking code only gives me the number of sells

(var google_conversion_value = 1) but not the total value.

 

hope you understand my english.

 

greetings from germany

 

mikepmm

 

you are just missing the queries before the checkout_success.php page is rendered, that you need to insert at the begining of your file

 

find:

 

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

 

just before, add

 

 

  
  /* ADDED TO GET ORDER TOTAL FOR GOOGLE ADWORDS CONVERSION TRACKING CODE VALUE */
 /* by Raphael Spindell <raphaelspindell@yahoo.com> */ 
 /* August, 2006 */

 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
 $orders = tep_db_fetch_array($orders_query);

 $orderstotal_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$orders['orders_id'] . "' order by sort_order desc limit 1");
 $order_total = tep_db_fetch_array($orderstotal_query);

 $order_total = round($order_total['value'], 2);
 $order_id = $orders['orders_id'];

 /* End GOOGLE ADWORDS (see below for Google's Script) */

 

Hope this helps!

Edited by pixclinic

Share this post


Link to post
Share on other sites

@pixclinic

 

I search around an find the code in the contribution that you have send here:

http://www.oscommerce.com/community/contri...arch,conversion

 

but without the bold red text - is this red text right?

 

 
  /* ADDED TO GET ORDER TOTAL FOR GOOGLE ADWORDS CONVERSION TRACKING CODE VALUE */
 /* by Raphael Spindell <raphaelspindell@yahoo.com> */ 
 /* August, 2006 */

 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
 $orders = tep_db_fetch_array($orders_query);

 $orderstotal_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$orders['orders_id'] . "' order by sort_order desc limit 1");
 $order_total = tep_db_fetch_array($orderstotal_query);

[b] [color="#FF0000"]$order_total = round($order_total['value'], 2);
 $order_id = $orders['orders_id'];[/color][/b]

 /* End GOOGLE ADWORDS (see below for Google's Script) */

 

Then I went to adwords and put as the value instad of 1 this into the box:

<?php echo round($order_total['value'],2);?>

 

Then google adwords give me this:

 

<!-- Google Code for purchase Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = xxxxxxxxxx;
var google_conversion_language = "en_US";
var google_conversion_format = "1";
var google_conversion_color = "FFFFFF";
if (<?php echo round($order_total['value'],2);?>) {
 var google_conversion_value = <?php echo round($order_total['value'],2);?>;
}
var google_conversion_label = "purchase";
//-->
</script>
<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0 src="http://www.googleadservices.com/pagead/conversion/xxxxxxxxxx/?value=[color="#00FF00"][b]<?php echo round($order_total['value'],2);?>[/b][/color]&label=purchase&script=0">
</noscript>

 

is this correct as the code from the contribution with the link above is different in the bold green part -

in the contribution there is a 1 instead of the bold green text.

 

greetings from germany and thanks for your help

 

mikepmm

Share this post


Link to post
Share on other sites

Hi we have Google Analytics module running on 2 sites that both have a number of mods running on them. Everything is working fine however the Goals are not registering. We have goals setup for Checkout and newsletter signup.

 

If there is anyone who is an expert with Google Analytics and OSC please PM me with your rates. We are looking to get this solved at once.

 

Thanks!

Jesse

Share this post


Link to post
Share on other sites
Then I went to adwords and put as the value instad of 1 this into the box:

<?php echo round($order_total['value'],2);?>

 

you certainly don't enter any php in Google Analytics fields! Just leave the field blank as Google itself tells you:

 

"Make sure to leave the Goal Value field blank, so that Google Analytics knows to look for your e-commerce information as the goal value."

Share this post


Link to post
Share on other sites
Whenever someone orders through PayPal they are followed upto the checkout page but then lost so within the e-commerce reports of Google we're loosing a values.

 

I've sorted this thanks, it turns out the previous developer hadn't setup the IPN callback correctly.

Share this post


Link to post
Share on other sites

Has anyone played with the new analytics web optimizer from google? It looks promising however google states dynamic sites may have problems 'testing' different versions...

 

Thomas


A signature is something that reflects its user. - The dictionary

 

The question is not, 'to code, or not to code'

the question is, 'if we do not code, are we really alive?'

-- anonymous

Share this post


Link to post
Share on other sites

Hiya Guys

 

I was wondering if someone can help me.

 

I have just noticed that Google Analytics doesn’t report the same sales totals as oscommerce. For example Google analytics may have £5000 1000 orders with 2000 items but in reality this was £5500 1050 orders with 2100 items.

 

I cant figure out why its showing this discrepancy as it seems to be working fine. It looks like some paypal transactions might be the problem.

 

Any ideas?

Share this post


Link to post
Share on other sites
Hiya Guys

 

I was wondering if someone can help me.

 

I have just noticed that Google Analytics doesn’t report the same sales totals as oscommerce. For example Google analytics may have £5000 1000 orders with 2000 items but in reality this was £5500 1050 orders with 2100 items.

 

I cant figure out why its showing this discrepancy as it seems to be working fine. It looks like some paypal transactions might be the problem.

 

Any ideas?

Wouldn't that correspond to 5% of people that have javascript disabled in their browser ?

You coder might also have missed something in the setup - who knows :-" , but I personally think it is because of the javascript :blink:


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×