nuxt-community / google-gtag-module

Enable google gtagjs for NuxtJs
MIT License
145 stars 29 forks source link

Enhanced E-Commerce Tracking with this library? #33

Open simplenotezy opened 4 years ago

simplenotezy commented 4 years ago

How do I send enhanced e-commerce tracking with this library? Currently I have tried like so:

        this.$gtag('event', 'transaction', {
            ecommerce: {
                purchase: {
                    actionFields: {
                        id: '123',
                        revenue: '4.56',
                        tax: '0.00',
                        shipping: '1.00',
                        coupon: ''
                    },
                    products: [
                        {
                            id: this.product.id,
                            name: this.product.title
                        }
                    ]
                }
            }
        });

The event does indeed fire, but nothing shows up in Google Analytics.

Not sure if I have to approach this differently.

simplenotezy commented 4 years ago

I have also tried with:

        this.$gtag('event', 'purchase', {
            transaction_id: '123',
            value: 4.56,
            currency: 'EUR',
            tax: '0.00',
            shipping: '1.00',
            coupon: '',
            items: [
                {
                    id: this.product.id,
                    name: this.product.title,
                    price: '123',
                    quantity: 1
                }
            ]
        });

Same issue. Event gets fired, but no data show up in Analytics or in "GTM/GA Debugger for Chrome" under Enhanced E-commerce tab.

simplenotezy commented 4 years ago

After several attempts to modify the event data in different ways, and hours of debugging, I failed to get enhanced e-commerce tracking to work with this library.

I instead tried my luck with https://github.com/mib200/vue-gtm and it worked after 5 minutes.

I can send a purchase event like so:

        this.$gtm.trackEvent({
            event: 'transaction',
            ecommerce: {
                purchase: {
                    actionFields: {
                        id: '123',
                        revenue: '4.56',
                        tax: '0.00',
                        shipping: '1.00',
                        coupon: ''
                    },
                    products: [
                        {
                            id: this.product.id,
                            name: this.product.title
                        }
                    ]
                }
            }
        });
nachiomdq commented 4 years ago

It's and old post, but thanks @simplenotezy i was stuck on the same problem. I will try to move to vue-gtm, because this module doesn't work at all with transactions.