On the "Thank You" page from an ecommerce transaction, I have used the Google Analytics tool to log the transaction. As part of this, I have used the 'set' feature to add some tracking data:
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '123456',
'affiliation': '',
'revenue': '9.99',
'shipping': '1.11',
'tax': '0.00'
});
ga('set', {
'dimension5': 'Mr',
'dimension6': '1968',
'dimension7': 'G4'
});
ga('ecommerce:send');
This is all working fine. However, I have a search box on the sidebar of all pages, which I also track using Google Analytics. Normally this behaves perfectly, but if a user has just completed a transaction and uses the search box on that page, the custom dimensions are included in the details of that event.
How do I clear the custom dimensions completely? The API notes don't say, and the only reference I can find on a Google search recommends setting them to the empty string. This at least gets rid of the unwanted data, but the custom dimensions are still logged.
Custom dimensions and metrics can't be deleted once created, but you can return to these settings in your account to manage and edit them. To stop using an existing custom dimension, uncheck the Active box, and click Save.
You can remove metrics by clicking on the “x” symbols next to them, or add metrics if space allows.
The name of a Custom Dimension can be changed at any time. Values of Custom Dimensions are limited to 255 characters whereas Custom Variables are limited to 200.
The correct way to get rid of them is to set the dimensions to null immediately after making the ecommerce:send call, like so:
...
ga('ecommerce:send');
ga('set', {
'dimension5': null,
'dimension6': null,
'dimension7': null
});
This will remove all reference to them from the 'collect' query string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With