I'd like to know how to get the E-commerce transaction ID from a Google Analytics tracker object.
I already found the tracker.get()
method: https://developers.google.com/analytics/devguides/collection/analyticsjs/accessing-trackers
By using tracker.get('clientId')
, I successfully obtained the client ID from the Analytics tracker object.
According to the Analytics debug log, there is some transaction data stored in the Analytics tracker object with 'ec:id' as the transaction ID field. I tried to obtain the value of this field by using tracker.get('ec:id')
, but this didn't return any result.
Inspect your tracker in the console. The following checks the first tracker, for example:
ga.getAll()[0];
Inspect the data
field, then inspect the keys
field. It'll be an array of what you can pass to a tracker's .get()
method.
I suggest you try getting the _ti
out of your tracker:
ga.getAll()[0].get('_ti');
If it corresponds with the transaction ID, then I did not screw up.
You should be able to reference the parameter by itself by using the ampersand syntax. Documentation
Reference for field parameters
So for your case:
tracker.get('&ti')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.