Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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!

share|improve this question

marked as duplicate by Su', John Conde Jul 29 '12 at 18:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
What do you mean "reverse an analytic"? –  John Conde Jul 2 '12 at 16:28
    
Hi, This code was copied from support.google.com/analytics/bin/… in an attempt to reverse a google analytics entry. Thanks! –  Dan Jul 2 '12 at 18:32
    
am not understanding this question..you want to reverse an e-commerce transaction? –  Random Guy Jul 3 '12 at 9:20
    
Yes, I want to reverse an e-commerce transaction. –  Dan Jul 3 '12 at 15:56
add comment

1 Answer 1

Using the link provided by Dan, http://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
]);
share|improve this answer
    
Hi Thank you for your answer. Unfortunately, I have tried the code with both positive and negative 25 and the record still persists in GA. –  Dan Jul 3 '12 at 16:29
    
If you have tried both the positive and the negative would they not effectively cancel each other out in the transaction total? Also, did you read from the link you supplied: "Reversing a transaction does not remove it. Both the original transaction and the reversal transaction are included in the transaction count." –  MrG Jul 4 '12 at 12:40
    
I did read the post I provided but missed any reference to both orig and rev trans remaining in the trans count. –  Dan Jul 9 '12 at 20:48
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.