Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Google Ecommerce Installation


Recommended Posts

Can anyone help me out ?

 

Basically I have installed both of these contributions :

 

GOOGLE ADWORDS CONVERSIONS

http://addons.oscommerce.com/info/4494

 

GOOGLE ANALYTICS

http://addons.oscommerce.com/info/5037

 

I am getting data back to my analytics but I'm not getting the Ecommerce data back.

 

I have done everything in the attached code as advised by the contribution

 

Am I missing something

 

Google Analytics E commerce Integration

 

 

This is a small hack put together to enable google analytics transaction tracking, I am by no way a programmer, if you have corrections. Please submit them. This is a pretty easy addition to your checkout system, it does require that you have a google analytics account setup for your site as an ecommerce site. You MUST also have the google tracking code installed on your site, (if you need help with that there is a contribution for that http://www.oscommerce.com/community/contributions,3756)

Please ensure that you either include the google tracking code from the footer of the document. OR ensure that where ever you put it in checkout_success.php it is after the call to urchin.js or the function __utmSetTrans() wont be defined and you will get errors in your JS console.

 

NOTE: My version is OSC is heavily modified. Line numbers will not match up to yours.... good luck.

 

We will be modifying two files for this

/catalog/checkout_process.php

/catalog/checkout_success.php

 

 

 

Good Luck

Shane

 

 

------- INSTRUCTIONS --------

backup your whole /catalog folder

backup your whole database

This is always a good way to start the day, helps for when you accidentally breaksomething

 

backup /catalog/checkout_process.php

 

Starting in /catalog/checkout_process.php

 

Right Around Line 13

 

include('includes/application_top.php');

 

 

----- ADD IN BELOW IT -----

 

// GOOGLE ANALYTICS BOF

// Reset the two variables in case we are processing a second order in the same session.

 

$_SESSION['google_analytics'] = '';

$google_analytics = '';

 

// GOOGLE ANALYTICS EOF

 

 

 

 

 

Half way down the page around line 227

 

tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

$order_products_id = tep_db_insert_id();

 

 

 

----- ADD IN BELOW IT -----

 

// GOOGLE ANALYTICS BOF

 

$category = 'NULL';

 

$prod_category = tep_db_query("select c.categories_name as cname from categories_description as c, products_to_categories as p where p.categories_id = c.categories_id and p.products_id = '". $order->products[$i]['id'] ."' limit 1");

 

if (tep_db_num_rows($prod_category) > 0) {

$pc_values = tep_db_fetch_array($prod_category);

$category = $pc_values['cname'];

}

 

$google_analytics .= 'UTM:I|'.$insert_id.'|'.$order->products[$i]['model'].'|'.$order->products[$i]['name'].'|'. $category .'|'. $order->products[$i]['price'].'|'.$order->products[$i]['qty']."\n";

 

 

// GOOGLE ANALYTICS EOF

 

 

 

 

 

 

Next addition goes below this line, roughly Line 273

 

$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";

 

 

----- ADD IN BELOW IT -----

 

// GOOGLE ANALYTICS BOF

 

// Peter Anderson added the following line to register the session:

session_register('google_analytics');

 

$_SESSION['google_analytics'] = 'UTM:T|'.

$insert_id .

'|Web Sales|'.$order->info['total'].'|'.

$order->info['tax'].'|'.

$order->info['shipping_cost'].'|'.

$order->customer['city'].'|'.

$order->customer['state'].'|'.

$order->customer['country']['iso_code_2']."\n".$google_analytics;

 

 

// GOOGLE ANALYTICS EOF

 

 

Close the file.

Open up /catalog/checkout_success.php

 

At the bottom of the file, below the footer include line

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

 

Insert this code.

 

 

// GOOGLE ANALYTICS BOF

<!-- Google analytics transaction tracking -->

<form style="display:none;" name="utmform">

<textarea style="display:none;" id="utmtrans">

<? echo $_SESSION['google_analytics']; ?>

</textarea>

</form>

 

<script type="text/javascript">

__utmSetTrans();

</script>

<?

// reset these bits.

$_SESSION['google_analytics'] = '';

tep_session_unregister('google_analytics');

 

// GOOGLE ANALYTICS EOF

?>

 

That should be it, ensure when testing this that you dont have filters in google analytics setup to ignore your IP, it could keep your orders from being tracked. Make sure to check your handy dandy Javascript console for errors and view source to ensure everything shows up.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...