Closed cesarvarela closed 7 years ago
commit seppuku
:rofl:
Well, I'm open to suggestions, but because we're not responsible for booting up Google Analytics itself with the plugin, and because we need to do detection to tell which version we're using, it seemed smart to just let the handler fail silently. Open to suggestions! I had had a console.log in there but we got some complaints about it clogging up test suite output.
Oh, also, to answer your question in the title - you don't need to enable it, you can just use the transactionTrack method on $analytics
.
If you're using Enhanced Ecommerce, then you need to set $analyticsProvider.settings.ga.enhancedEcommerce
to true
in your conf.
I'm going to mark this closed; let me know if you still need a hand.
I'm using angulartics-google-tag-manager and I'm not sure how I could go about using transactionTrack
on that context. Any hints?
Thanks!
@avilaton Currently the GTM lib doesn't support transactions, it's behind. Haven't found the time to put it in yet.
I read through the code of both plugins and am willing to take a wack at it. I tried hacking something together but I guess I need to load the ecommerce extension some how, not sure how yet.
You're headed down the wrong path; the plugin stuff is handled by GTM. All we need to do is push the transaction to the dataLayer in this format for EE:
https://developers.google.com/tag-manager/enhanced-ecommerce#purchases
And this format for "traditional" ecommerce:
dataLayer.push({
'transactionId': '1234',
'transactionAffiliation': 'Acme Clothing',
'transactionTotal': 38.26,
'transactionTax': 1.29,
'transactionShipping': 5,
'transactionProducts': [{
'sku': 'DD44',
'name': 'T-Shirt',
'category': 'Apparel',
'price': 11.99,
'quantity': 1
},{
'sku': 'AA1243544',
'name': 'Socks',
'category': 'Apparel',
'price': 9.99,
'quantity': 2
}]
});
The best option (IMO) is to push it in a neutral format and then use a Variable in GTM to re-format it for the vendor, since GTM is designed (like angulartics...) to serve multiple vendors. GL!
I should add that once the data is pushed in, a Tag needs to be created to take care of the data. For EE that should be an Event with the Enhanced Ecommerce setting enabled, for traditional there's a Transaction hit type. It's all very complicated.
Hi @DanWilkerson thanks for the pointers, I think I've made some progress. I changed code in angulartics-google-tag-manager
sort of like this:
$analyticsProvider.registerTransactionTrack(function (transaction) {
var dataLayer = window.dataLayer = window.dataLayer || [];
dataLayer.push(transaction);
});
and tested firing with:
$analytics.transactionTrack({
'event': 'transaction',
'transactionId': '1234',
'transactionAffiliation': 'Acme Clothing',
'transactionTotal': 38.26,
'transactionTax': 1.29,
'transactionShipping': 5,
'transactionProducts': [{
'sku': 'DD44',
'name': 'T-Shirt',
'category': 'Apparel',
'price': 11.99,
'quantity': 1
},{
'sku': 'AA1243544',
'name': 'Socks',
'category': 'Apparel',
'price': 9.99,
'quantity': 2
}]
});
while also adding to my tagmanager acount a:
transaction
which is a key I added to the payload above,I'm using a chrome extension to debug this hole mess and it looks like the ecommerce extension is loaded, and the event is successfully parsed and fired. I'm yet not able to see it show up in my google analytics real-time panel, do you have any ideas about what might be going on?
Seems like the plugin commits seppuku:
https://github.com/angulartics/angulartics-google-analytics/blob/master/lib/angulartics-ga.js#L361
Why is that?
btw. i'm using angulartics with the oogle tag manager plugin