Google Analytics | Ecommerce Tracking: How to Avoid Page Reloads Tracking?

I have set up Google ecommerce tracking by supplying the required JavaScript code on the order receipt page. However, if the user reloads the page (or comes to it without actually making a purchase), won't the order be counted again?

How can I make sure that every order is counted once and only once?

+3


source to share


1 answer


First, your application should probably be designed in a homestead that will not allow users to directly access an On-Order page, they should only be available as a result of a shopping cart checkout process. Depending on your server technology, you can usually restrict this by only accepting certain HTTP verbs (methods), such as only allowed POST operations.

Second, check out the documentation addTrans()

. So if your application allows users to refresh the page that tracks transactions, then registering the same ecommerce data for the same orderId will simply overwrite the old data with the new data - which may be the same depending on how your application is structured.



Anyway, I highly recommend not allowing users to refresh this page if you are tracking Google Analytics. When an order is placed on our website, we delete the shopping cart and return the user to the GA ecommerce tracking order receipt page. Then, if anyone tries to access that page again and their cart is empty, you will be redirected to the Orders page where they can view recently placed orders (no GA e-commerce).

Hope this helps!

+2


source







All Articles