Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2008
    Posts
    38
    Plugin Contributions
    0

    Default Ecommerce Tracking code for Google Analytics

    I'm trying to implemetn the Ecommecre Tracking code to use in Google Analytics.
    I'm not interested in installing any of the module, would like to just put the tracking code on the checkout_success.php page.
    Below is what I've added to this file so far. Can someone tell me if this is correct, or point me in the right direction?
    The code worked with manually filled fields, but haven't registrered any purchases with this code yet:

    <script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxxx-x']);
    _gaq.push(['_trackPageview']);
    _gaq.push(['_addTrans',
    '.$order->fields['orders_id'].', // order ID - required
    'Store Name', // affiliation or store name
    '.$orders['ot_total'].', // total - required
    '.$order->fields['ot_tax'].', // tax
    '.$order->fields['ot_shipping'].', // shipping
    '.$order->fields['city'].', // city
    '.$order->fields['state'].', // state or province
    '.$order->fields['country'].' // country
    ]);

    // add item might be called for every item in the shopping cart
    // where your ecommerce engine loops through each item in the cart and
    // prints out _addItem for each
    _gaq.push(['_addItem',
    '.$order->fields['orders_id'].', // order ID - required
    '.$products->fields['skucode']', // SKU/code - required
    '.$products->fields['products_name'].', // product name
    '.$category->fields['categories_name'].', // category or variation
    '.$products->fields['final_price'].', // unit price - required
    '.$products->fields['products_quantity'].' // quantity - required
    ]);
    _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

    </script>

    Cheers
    Endre

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,762
    Plugin Contributions
    9

    Default Re: Ecommerce Tracking code for Google Analytics

    What exact file are you adding this to??
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Dec 2008
    Posts
    38
    Plugin Contributions
    0

    Default Re: Ecommerce Tracking code for Google Analytics

    /templates/tpl_checkout_success_default.php.
    This is the correct file, isn't it?
    Google Analytics registrered my first test with pre filled fields.
    Now, it's a matter of getting the dynamic fields right, so product name, price, shipping, tax etc is sent to Analytics when a order is placed.

  4. #4
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,762
    Plugin Contributions
    9

    Default Re: Ecommerce Tracking code for Google Analytics

    Try adding it to
    /includes/modules/pages/checkout_success/html_header.php
    Zen-Venom Get Bitten

  5. #5
    Join Date
    Dec 2008
    Posts
    38
    Plugin Contributions
    0

    Default Re: Ecommerce Tracking code for Google Analytics

    Ok, will try that, but why?
    Google registered the tracking code when I had prefilled the fields when placed in /templates/tpl_checkout_success_default.php.
    So you think the fields are correct?

    '.$order->fields['orders_id'].', // order ID - required
    'Store Name', // affiliation or store name
    '.$orders['ot_total'].', // total - required
    '.$order->fields['ot_tax'].', // tax
    '.$order->fields['ot_shipping'].', // shipping
    '.$order->fields['city'].', // city
    '.$order->fields['state'].', // state or province
    '.$order->fields['country'].' // country

    '.$order->fields['orders_id'].', // order ID - required
    '.$products->fields['skucode']', // SKU/code - required
    '.$products->fields['products_name'].', // product name
    '.$category->fields['categories_name'].', // category or variation
    '.$products->fields['final_price'].', // unit price - required
    '.$products->fields['products_quantity'].' // quantity - required

  6. #6
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,762
    Plugin Contributions
    9

    Default Re: Ecommerce Tracking code for Google Analytics

    I only stated that you could "TRY" that file
    Zen-Venom Get Bitten

  7. #7
    Join Date
    Dec 2008
    Posts
    38
    Plugin Contributions
    0

    Default Re: Ecommerce Tracking code for Google Analytics

    Ok, then I think I'll stick with the file I already know works.
    The issue I wonder about is the different fields, if these are correct.

    Cheers

  8. #8
    Join Date
    Dec 2008
    Posts
    38
    Plugin Contributions
    0

    Default Re: Ecommerce Tracking code for Google Analytics

    Have put the code in the tpl_footer.php and put it in a new folder called checkout_success in the templates folder, so the Analytics code doesn't appear twice on the same page. I have the ordinary tracking code set up in tpl_footer.php.
    I'm still missing the different variables in the ecommerce tracking code.
    I've tried to look at the Simple Analytics module and the code, but haven't figured it out yet.
    Here's what I've tried with (have tried different variations of this):

    \"". $order->fields['orders_id'] . "\", // order ID - required
    'Sykkelsport AS', // affiliation or store name
    \"". $order->fields['ot_total'] ."\", // total - required
    \"". $order->fields['ot_tax'] ."\",, // tax
    \"". $order->fields['ot_shipping'] ."\", // shipping
    \"". $order->fields['city'] ."\", // city
    \"". $order->fields['state'] ."\", // state or province
    \"". $order->fields['country']."\" // country
    ]);

    // add item might be called for every item in the shopping cart
    // where your ecommerce engine loops through each item in the cart and
    // prints out _addItem for each
    _gaq.push(['_addItem',
    \"". $order->fields['orders_id'] . "\", // order ID - required
    \"". addslashes($products->fields['skucode']) ."\", // SKU/code - required
    \"". addslashes($products->fields['products_name']) ."\", // product name
    \"". addslashes($category->fields['categories_name']) ."\", // category or variation
    \"". number_format($products->fields['final_price'], 2, '.', '') ."\", // unit price - required
    \"". $products->fields['products_quantity'] . "\" // quantity - required

    Have also tried to find the variables from the tpl_checkout_process.php file, but only a couple of the ones required are there as far as I can see.

    Any help would be greatly appriciated.
    Cheers
    Endre

 

 

Similar Threads

  1. Replies: 22
    Last Post: 20 Sep 2021, 02:38 AM
  2. v139h Google Analytics Conversion Tracking code install
    By split63 in forum General Questions
    Replies: 7
    Last Post: 17 Dec 2015, 04:09 AM
  3. Where to put google analytics tracking code???
    By cmike in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 23 Apr 2014, 08:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR