I've set up GA ecommerce tracking by putting the required JavaScript code on my order receipt page. However, if the user reloads the page (or arrives to it without actually completing a purchase), won't the order be counted again?
How can I make sure each order is counted once and only once?
First off, your application should probably be designed in a manor that would not allow users to access an "Order Placed" type page directly, they should only be able to get there as a result of shopping cart checkout process. Depending on your server technology, you can usually limit this by only accepting specific HTTP Verbs (methods) such as only allowing POST operations.
Secondly, check out the addTrans()documentation. So if your application allows users to refresh a page that is tracking transactions, then logging the exact same ecommerce data for the same orderId will just overwrite the old data with the new data - which may be the same depending on how your app is structured.
Either way, I strongly recommend not allowing your users to refresh this page if you that is where you are tracking Google Analytics. When an order is placed on our website, we clear out the shopping cart and return the user to an order receipt page with the GA ecommerce tracking. Then, if anybody tried accessing that page again and their cart is empty, the get redirected to the "Orders" page where they can review recently placed orders (no GA ecommerce).
Hope this helps!
Related
I have installed the google analytics in our e-commerce site using google tag manager. From the product detail page you can click on the colors to see the same product in the different colors. I implemented this using ajax so the page load is not required. I was curious if the google analytics will count as multiple reviews a user clicks on the different colors or do I need to explicitly call something in order for the GA to count as multiple reviews.
First of all, that depends how and what kind of GA you've implemented.
To implement analytics, you have to specify a trigger for the analytics tag. That trigger normally determines if a tag is fired or not.
If you used a page load trigger, then the tag will only be triggered on the real page load. And it won't be triggered on your ajax manipulations.
With only one exception: if you used the GA4 config tag, you had this checkbox there:
The checkbox doesn't only send the pageview on config load, it keeps sending pageviews on every history change. Therefore, if your ajax causes history change and you use the GA4 config tag, then you're getting pageviews.
But this is theory. You can just go and check. Open your network tab, filter the request by collect and see what's sent when. Or alternatively, install the adswerve datalayer debugger and it will log whatever is sent whenever it's sent into the console in a very neat, clean way. This is how it works on this page:
I have a problem with google analytics and stripe checkout where all goal completions are attributed to checkout.stripe.com, instead of the actual referring website.
I am using Google Analytics UA and have the Global site tag on all pages. Then I have a goal to track the success page, which stripe checkout redirects to upon successful completion.
User flow:
Website visitor comes from one of the referral pages.
Then they click on the stripe checkout button, which takes them to a stripe hosted page.
On stripe hosted checkout page, enter payment info.
Upon successful payment, redirected to success.html (which is the goal being tracked in analytics).
So when a user goes to success.html, Google analytics attributes the goal completion to stripe checkout, instead of the website that referred them to my site in the first place.
Has anyone else experienced this? Am I doing something wrong or is this just how Google Analytics works when using Stripe Checkout?
This seems like a GA configuration issue rather than Stripe. I'm not really familiar with GA, but if there's some way you can override the attribution, Stripe Checkout lets you set your success_url dynamically. For example, for each customer sent to Checkout, you could include the original referrer in the success URL they'd ultimately be sent to, in addition to getting the Checkout session ID in case you'd like to retrieve some session data (like metadata):
success_url: "http://example.com/success.html?original_referral=ref_123&session_id={CHECKOUT_SESSION_ID}",
https://stripe.com/docs/payments/checkout/custom-success-page#modify-success-url
not sure if you have solved this yet but you can block certain referral urls. Go to analytics go to admin> set up assistant > tag installation> click on your data stream > more tagging settings > list unwanted referrals> then from there just exclude the url you don't want tracked so in your case it's checkout.stripe.com
We have a problem with E-Commerce transactions sometimes not beeing set in relation to an ad click ("cpc"). They appear instead with the Channel/Medium "direct". This is a problem as we cannot correctly link our revenue to the costs spend on Google Ads.
We got a payment system that allows buyers to safely pay to sellers, and we get a fee percentage of the payment volume (similar like PayPal). We get our fees as soon as a pay-in is successful. Because our users can pay via bank wire as well it may take one or two days until we actually get our fee. This is why ecommerce transactions are not sent from the frontend to GA (on a thank-you page like in online shops), but from our server directly to GA as soon as a payment succeeds.
This is the GET call our server does when a payment succeeds:
GET https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-1&cid=1746XXXXX.1593XXXXXXX&t=transaction&ti=mytransactionID&tr=1&cu=USD
Here is a small diagram that explains the process:
We use cross-domain tracking, and the GA Client ID of the users stay the same when they get redirected from mydomain.com to app.mydomain.com, so this should not be the problem. What I assume is, that when a user clicks on an ad, the gclid of the ad is lost. Is there a way to manually send the gclid ID to Google Analytics? I would store the gclid then as well in our payment. Or is there another (maybe better way) to send transactions to GA?
Your transaction hit will only be attributed to ad-click session if payment occurs in a 30-minutes interval since the last hit with the same ID. Otherwise, the transaction hit would start a new session. Due to 'last-non-direct' rule the new session would only be associated with "cpc" channel if there were no other intermediate sessions after ad click. Please check the Google Analytics extensive overview for deeper insight.
Storing and passing gclid might help, however, this might result in some discrepancies in cost reporting since there would be several sessions for the same click. In the case of passing gclid it's recommended to pass at least two hits:
a simple pageview hit with a dummy location parameter containing gclid
and then later a transaction hit with the same location paraeter. In that case you'll be able to see your transactions as a separate sessions with a distinct landing pages
You should make sure you're using the GA client id in the Measurement protocol hit to ensure the hit gets stitched to the other hits of that user.
Now regarding reporting: Google Analytics uses the attribution model "Last non-direct Click", despite the hit being sent later, GA will ignore direct and use the previous touch point which should be the PPC campaign.
There shouldn't be an issue there. Which report are you using to see the transaction appear as direct, rather than Paid Search?
I add Enhanced Ecommerce in my GA tracking, all steps tracking fine, except CheckOut to Transaction, two action not linked together (has checkout but shows 0%).
P.S. I user third Third-Party Payment and in my test enviroment, staging GA,two action links OK. So I think maybe I miss some GA setting?
I think what's happening here is that you have not added the third party payment gateway to your referral exclusion list. Therefore, every time a user returns to your site after paying, this is triggering a new session in GA (with a new source/medium). This is why you see 1 session with transactions but 0% funnel carry through. Try adding the domain of your payment gateway by following the instructions here.
I've been tasked with enabling Google Analytics ecommerce tracking on a client's website. I've read Google's documentation on the subject, but it made little reference to tracking conversion data, which is a feature that our client has asked for.
My question is this: on which page(s) do I need to add information regarding items/transactions? We have pages for shopping cart, payment info, confirmation, and receipt. The Google documentation only mentions putting this code on the receipt page, but I feel as though this wouldn't give us the information necessary to track conversions. Is Google Analytics able to track this information simply by virtue of having the general page tracking code on each page, or does transaction info need to be tracked across all of our checkout pages?
You only need the item/transaction tracking code (_addTrans(), _addItem(), & _trackTrans()) on one page, after the purchase has occurred -- in your case it sounds like the receipt page.
You do need to make sure that the general analytics code is on every page, including the checkout and receipt pages, otherwise you can lose the chain of tracking data leading up to the conversion.