2.5K members online now
2.5K members online now
Use AdWords conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me

Edit Ecommerce tracking code

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi Everyone,


How could be edit ecommerce tracking code.  I have no idea regarding this kindly suggest me or provide editable code. Thanks in advance.  


-------------------------------------SAMPLE CODE------------------------------


<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-********-1']);   //   GOOGLE ANALYTICS ID

'1234', // order ID - required
'Womens Apparel', // affiliation or store name
'28.28', // total - required                


// But how could we edit these string values provide some example for me reagrding these fields eg tax, shipping, city

'1.29', // tax
'15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
'1234', // order ID - necessary to associate item with transaction
'DD44', // SKU/code - required
'T-Shirt', // product name
'Olive Medium', // category or variation
'11.99', // unit price - required
'1' // item quantity - required

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

Marked as Best Answer.
Accepted by topic author Anil Guleria
September 2015

Re: Edit Ecommerce tracking code

Top Contributor Alumni
# 2
Top Contributor Alumni

Hi Anil

// Transaction Data
= array('id'=>'1234','affiliation'=>'Acme Clothing',

// List of Items Purchased.
= array(

You will need to work with PHP or any other server side scripting like example above and then pass the data to GA code like

// Function to return the JavaScript representation of a TransactionData object.
function getTransactionJs(&$trans){

// Function to return the JavaScript representation of an ItemData object.
function getItemJs(&$transId,&$item){

The example I have given above is for Universal analytics but logic will be same for asynchronous code as well. If you are not a coder then you can either get a coders help to write this code or if you are using a shopping cart software like magento , Oscommerce, etc most of shopping carts have some module/plugin which actually takes care of this automatically without you writing any code.

Hope this helps




Regards, Nik
LinkedIn  |   @nikhilparachure | My Blog