Google Analytics Ecommerce / Difference between 'ec:addItem', 'ec:addTransaction' and 'ec:send' - google-analytics

I would look for some feedback on tracking user activity on an commerce website using th google analytics commerce capabilities.
I can't fully understand those 3 parts :
Adding an item (ecommerce:addItem) : obviously when some user add a thing to the cart
Adding a Transaction (ecommerce:addTransaction) : that's where I'm very confused
Sending the data (ecommerce:send) : that's obvious
Can those 3 event append at a different moment ? in what manner ?
What would be a real-world use case that would make you use execute ecommerce:addTransaction and ecommerce:send at a different moment ?
This thing makes me wonder a lot, and I'd like to have some experienced feedback on this as you tend to easily break your stats if something is not done week enough
Thanks in advance
EDIT
So the main purpose right here is to get stats for the pending orders (you add stuff to your cart), and the complete orders (you paid for the things you added).
Right now I only send it all when the order is complete, and things are working pretty good in analytics, but I just don't know anything about the ones that did not complete.

This question was a lack of knowledge.
Simple ecommerce plugin has nothing to do with the enhanced ecommerce plugin
You won't track that much with the first one, except the checkouts. A plain, one order at a time, revenue value.
If you want a deep insight on your users behaviors (when i say deep, I mean it), You have to go for the second one.
We might be able to debate over the unusefullness of the first one; and the fact that its existence in itself compared to the second is completely misleading, as when you first get in, as usual with google, you get flooded by an endless documentation

ecommerce:addItem does not add items to a cart; it adds items to a transaction (with "conventional" ecommcerce tracking there is no cart tracking, you'd have to use enhanced ecommerce tracking. Actually your title refers to enhanced ("ec:") and your question to conventional ecommerce ("ecommerce:") tracking).
So ecommerce:addTransaction starts a transaction; here goes the stuff that affects the transaction as a whole, like transaction id, tax on the total purchase or shipping costs.
Now that you have started the transaction you can add items to it that are associated via the transaction id.
Finally the ecommerce:send command tells Universal Analytics that the transaction should be processed on the server. "send" is actuall a misnomer; addItem and addTransaction do already send data to the server (they each create an request to the tracking server and thus count towards your hit quota).
The reason for this is, as far as I can tell, that the information is transmitted via url parameters (you call the Google Analytics endpoint which returns an transparent pixel). The maximum length for an url request is limited (actual limits depend on browser and browser version).
So the transaction is broken up into multiple parts not because you want to execute the commands at different moments but so it can be transmitted via Url parameters without being truncated. The send command merely tells that you are now finished adding new parts to the transaction and the data can now be processed.

Related

Is it possible to selectively delete data (specifi page URLs) from Google Analytics?

I'm pretty sure the answer to this question is "no", but I would like to get a definitive answer from an official source, and also understand what my alternative options might be.
Long story short, my app has old data in it that used to include user email addresses as a GET parameter. Those URLs are showing up as unique page view URLs in Google analytics, like this:
I don't want to be recording email addresses in my Google Analytics account (for privacy reasons), and I have fixed the code that was causing this in the first place, but I also want to delete or scrub the old data that currently exists in Google Analytics.
From everything I've read, it doesn't sound like this is possible without completely deleting the property, maybe even the account?
To be clear, I am NOT interested in creating new views that don't include URLs with email parameters in them, or otherwise change the view and not the data. The data needs to be gone and be completely inaccessible to anyone with access to this Google Analytics account.
Here are the options I've come up with:
Delete the property and start over. I'm pretty sure this will
actually delete the collected data, but it's not clear to me if I
would have to actually delete the account itself to achieve that.
Set the data retention time to the lowest possible value (looks like 14 months right now) and wait 14 months for it to go away https://support.google.com/analytics/answer/7667196?hl=en
Perform some kind of magic to get in contact with an actual human at Google who could help me scrub or remove this data.
Does this sound right? Are there options I'm missing? If there's a way to do this through a Google API that would not be a problem.
If this is still a relevant issue. GoogleAnalytics provides a way to delete some data. Universal Analytics https://support.google.com/analytics/answer/9450800?hl=en and GA4 https://support.google.com/analytics/answer/9940393?hl=en&ref_topic=2919631
You are right: changing the data, that you have collected, and Google Analytics have already processed, is not possible. You have the option to make changes during processing with various filters, e.g. Search-and-replace filters, but as it is written in this official support article:
Like all filters, search-and-replace filters only apply to hits
collected after you've applied the filter to the view (filters cannot
change historical data).
Regarding you suggested options:
Deleting a view or property will result in a permanent loss of data after a 35 days period of waiting time. (While this could be undone.) So unless the requirement of scrubbing the collected PII is more important than having your historical data, this should not be a way to go. The same applies to deleting the whole account, so it would be enough to delete affected properties or views.
From the article you have linked as well, you can see, that data retention is about removing user and event level data, and it will not affect the data in aggregated reports. My understanding is, that an already created, page level report will keep showing the page with an email address:
Keep in mind that standard aggregated Google Analytics reporting is
not affected.
I hope these references help you to evaluate your options. Sorry for not being able to come up with a solution, but the basic concept is, as highlighted in this Google article:
Once Analytics processes the data, it’s stored in a database where it can’t be changed

Updating value of previously sent ecommerce transactions

I am installing ecommerce tracking for a pretty simple ecommerce site. I am tracking the conversion on the order confirmation page, recording the transaction ID and order value, and everything's working fine.
However, sometimes the system issues the customer an offer to make an additional purchase on the order confirmation page with a single click (some small accessories that are discounted). If the customer chooses to make an additional purchase, I would like to be able to update the previously sent conversion. I do not want to assign a new transaction ID, because that will artificially inflate my conversion rate. I have tried sending the new amount of revenue with the same transaction ID, however that does not seem to have consistent results (sometimes ignored, sometimes value is just doubled).
I cannot hold back sending the conversion to GA until the customer makes a decision, because oftentimes the customer simply exits the browser without stating whether he is going to accept or decline the offer - in this case no conversion data would be sent at all.
Any ideas? Is there something in the GA library that I'm missing for this situation? Thanks
Nope, there is nothing. Even if a transaction with the same id goes through it's internally treated as a second transaction w/r/t the conversion rate.
If you want to get really fancy you could try and collect the transaction hit on your own server, wait a few minutes to see if you need to add another product and add a queue time parameter to offset for the actual collection time before you send it to Google. While this would work in theory I am not sure it is really feasible in a production environment (and in any case it would probably be more work than it's worth).

Multiple Ecommerce Transaction because of cached webpage

I am stuck in a case where Google Analytics is recording multiple eCommerce transaction. We have added code on server side to execute GA eCommerce posting code only one time. Still this issue is reproducible for some transaction. The multiple eCommerce transaction are for same transaction Id but on different dates.
On research I found that this case is with small devices (mobile, tablet). The small devices browser caches whole webpage. And when the browser is opened it reload webpage from cache. So each time user opens the browser and page loads from cache hence the causing this issue.
Can anyone help me on this?
Thanks
"Ignore double transaction ids" would be quite a useful setting and we should try and make this a feature request. However at the moment it does not exist.
The only way I can think of would be to use an API script that selects the transaction ids for the last "n" days and then inserts a heap of filters via the management API to exclude hits with that transaction id. After some time (when the caches have presumably expired) you could throw out old filters. This would be only feasible if you have a small number of transactions (I think there is an upper limit to the number of filters a view can have).
Or if your transaction ids are somehow sequential (e.g. if they contain the date) you might be able to construct a regex that matches earlier parts of the sequence (e.g. previous dates) and only let's a transaction pass if it is higher up in the sequence than the last recorded transaction id (or does not let it pass if the date in the transaction id is lower than the current date - remember to update your filter at midnight).
Caveat: I have not actually tried something like this, but it sounds like it should work.

Google Analytics: How to overcome payload size restriction?

I use Google Analytics Enhanced E-commerce for some shops. On catalog page I have many products and I need to track their impressions. I do not track each product one-by-one, cause it will cause many requests, instead I add all of them through .ec:addImpression and then track entire pack by sending single pageview.
And everything was going well until I faced a problem, that on page with too many products requests to collect stopped working with no error. I've installed analytics debugger for Chrome and found out, that I've exceeded a payload limit, which is set to 8 KB (according to official documentation):
payload_data – The BODY of the post request. The body must include
exactly 1 URI encoded payload and must be no longer than 8192 bytes.
And this is fine, but here's my question: is there any way to overcome this restriction? Maybe some option or method, that will allow not to bother about payload size and it will be automatically split into proper chunks? Or at least a method to get a payload in run-time to check its size. I run through documentation and found nothing.
Note: currently I manually track a "safe" number (which was discovered by experience) of products added by addImpression and then send them by non-interaction pageview hit. Of course, this solves my problem, by I want to know if there's a built-in solution.
Another possibility is to send only true impressions, that is, only for those products/items that the user is actually seeing above the fold. Not all products that you are sending impressions for are actually seen by the user until they scroll down the page below the fold. So this would require a modification to the implementation where you send your impression data as the user scrolls down the page and reveals more products. You can likely send more information with each product and still not exceed the payload, and you get a more accurate measure of your impressions.
Create a product data import that matches your product ids to product to product attributes (name, category, price etc). Wait until the data is processed, then change your tracking code so that only product ids are sent.
That should shrink down the request body enough to send all products, and the ids will be joined with the imported data when the incoming hits are processed.
Imported data is not applied retroactively, so it'S important that you do the data import first.
AFAIK there is no way to get your payload size from google analytics and it's a crying shame that analytics.js does not handle this issue automatically since the analytics.js library which constructs the payloads is best suited to handle this and thus minimise load on Google's servers...
I like Eike's solution, though if your products change a lot it might require automation. As #nyuen implies - sending only real impressions may help and is more accurate.
Another trick is to send the impression one at a time. (As shown or on page load) This will require the smallest change and reduce the payload to well bellow the limit.

How to remove an e-commerce transaction?

I have implemented google analytics ecommerce tracking in my website. But there was a mistake while passing parameters to google analytics. My order get tracked but product sku code is not set.
Its a dummy order that i dont want show in any google analytics report.
Can you suggest how can i delete this order from google analytics?
I am afraid you cannot remove data from GA once it has been collected.
What you can do is:
hide it: create an Advanced segment, the transaction remains in your GA profile but at least it is not included in the reports.
make a copy: copy the profile and delete the old one (it means you lose historical data)
There is one more option:
1.- You could create a new transaction with the same amount in money, but with a negative sign. For example, if you have recored a transaction for 1,000 dollars, you could recreate it with a "-1000.00" amount. Doing this would "cancell" the wrong transaction.
Important: This will only work when the user sees a long period of time, including the wrong transaction and the fix.
Julien is right. You cannot remove the data.
There're a couple more options in addition to Julien's suggestions though
You can go to "Filters" option of the view and try to see if you can filter it out. Luckily, ecommerce transactions have their own category that can help you narrow down the variable you need to use. (screenshot attached)
Go a little more advanced than filters and use "Data Import" where you import the ecommerce transactions via a spreadsheet thereby overwriting the transactions for that day. So, what you would essentially do is take all the real transactions of ecommerce from your ecommerce application, export them to CSV and then upload it into GA without the test transaction.
Lastly, a tip: create a test profile for things like this.
One of the answers hinted at data imports (but in a way that would probably not have worked). Universal Analytics actually introduced a way to refund transactions (effectively canceling them out) via data imports. However this only works if the data was collected via enhanced e-commerce tracking. As per documentation:
In order to process refunds you need to have collected transaction
data with the ec.js plugin
With standard e-commcerce-tracking Omar Gonzales' answer is still the only working option (I'd like to add the additonal caveat that the negative transaction might be attributed to the wrong channel, so make sure to look at the source/medium/campaign data for the transaction you want to cancel out and supply that data via utm parameters).

Resources