Mobile app version of vmapp.org
Login or Join
Goswami781

: Google reverse an analytic Possible Duplicate: When reversing a Google Analytics e-commerce transaction is the per-unit price positive or negative? I am confused about what code must

@Goswami781

Posted in: #GoogleAnalytics

Possible Duplicate:
When reversing a Google Analytics e-commerce transaction is the per-unit price positive or negative?




I am confused about what code must be executed to reverse a google analytic. I have the following code pasted within a test page:

<body onLoad=”function()”>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25305776-3']);
_gaq.push(['_trackPageview']);

_gaq.push(['_addTrans',
'11455', // order ID - required
'-42.38', // total - required
'-2.38', // tax
'-15.00' // shipping
]);
_gaq.push(['_addItem',
'11455', // order ID - necessary to associate item with transaction
'Evan Turner Turningpoint™ Basketball Pants', // product name
'25.00', // unit price - required
'-1' // quantity - required
]);
_gaq.push(['_trackTrans']);

(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>


Is this correct? Thanks!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Goswami781

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly868

Using the link provided by Dan, support.google.com/analytics/bin/answer.py?hl=en&answer=1037443, the title of the question should probably "How to reverse an e-commerce transaction in google analytics"

For example someone cancels an order, this would capture that so google analytics has correct information.

Looking at the code, one thing is missing from "_gaq.push(['_addItem',"
The minus sign in '25.00', so it should be:

_gaq.push(['_addItem',
'11455', // order ID - necessary to associate item with transaction
'Evan Turner Turningpoint™ Basketball Pants', // product name
'-25.00', // unit price - required
'-1' // quantity - required
]);

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme