AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.2K members online now
4.2K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Ecommerce setup for multiple products

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi guys,

as stated in the title I'd like to setup Ecommerce to track our transactions for our two products, which one is free and the other one costs £10.
Firstly I have added the GTM script to my website. Secondly I created a Tag of type "Universal Analytics", track type of "Transaction" and added my tracking ID. Attached to this Tag is a custom event trigger that fires on a specific URL and it's event name is `transactionComplete`.
Assuming that the above is the right approach (correct me if I am wrong please!) and due to the fact that `transactionTotal` is required am I right to think that I need to insert two different data layers (hopefully they seem correct?) for each one of my products to my website ?
E.g 

 

 

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}', //taken from a URL variable
   'transactionTotal': 0.00,
   'transactionProducts': [{
       'sku': 'FREE',
       'name': 'Free product',
       'price': 0.00,
       'quantity': 1
   }],
   'event': 'transactionComplete'
});
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}',
   'transactionTotal': 10.00,
   'transactionProducts': [{
       'sku': 'PAID',
       'name': 'Paid product',
       'price': 10.00,
       'quantity': 1
   }],
   'event': 'transactionComplete'
});
</script>


Any help appreciated !

Regards,
Konstantinos

 

Re: Ecommerce setup for multiple products

Follower ✭ ✭ ☆
# 2
Follower ✭ ✭ ☆

Hey Konstantinos, 

do you have dataLayer Code exactly like this on your confirmation Page?

First part of your configuration seems right. But you only need one of the dataLayer pushes were its dynamically generated wich of your two products has been sold. 
For your free product it should be this:

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}', //taken from a URL variable
   'transactionTotal': 0.00,
   'transactionProducts': [{
       'sku': 'FREE',
       'name': 'Free product',
       'price': 0.00,
       'quantity': 1
   }],
   'event': 'transactionComplete'
});
</script>

--- your GTM Code ---


Check out this Page for reference: https://support.google.com/tagmanager/answer/6107169?hl=en

 

Best regards

 

Re: Ecommerce setup for multiple products

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Marc,

thanks for your answer. This is the guide I followed, along with some other online sources.
I haven't injected that script into the website yet, have been struggling with similar stuff quite a while so I thought to confirm that I am on the right path first..
I'm (or might be) a little confused where you mentioned that I need only one of the dataLayer pushes, you meant I should do something like that: 

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}',
   'transactionTotal': 0.00,
   'transactionProducts': [{
       'sku': 'Free',
       'name': 'Free product',
       'price': 0.00,
       'quantity': 1
   },
   {
       'sku': 'PAID',
       'name': 'Paid product',
       'price': 10.00,
       'quantity': 1
   }],
   'event': 'transactionComplete'
});
</script>

<!-- Google Tag Manager -->

?
If yes, since `transactionTotal` is required- and it should be 0 or 10-what should it's value be ?

Thanks,
Konstantinos

 

Ecommerce setup for multiple products

Follower ✭ ✭ ☆
# 4
Follower ✭ ✭ ☆

Yeah if both items have been bought in the same order this above is the correct code.

Transaction Total should be 10 then since the total value of this transaction is 10€.

Example if you sold multiple paid products:
Quanitity: 3

price: 10

transactionTotal: 30

 

If only one of the products has been bought only one should appear in the dataLayer push.

 

Ecommerce setup for multiple products

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Hi Marc,

thanks again for your reply!
What you are saying makes total sense but in our case it's not possible to purchase both free and paid product at a single transaction(sorry I should have mentioned this before but I am really new with this stuff). Does that change anything or I should keep the latest code and set `transactionTotal` to 10 ?

Thanks,
Konstantinos

Re: Ecommerce setup for multiple products

Follower ✭ ✭ ☆
# 6
Follower ✭ ✭ ☆

In your dataLayer push there should be only the bought product. So when the free version is bought you have this: 

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}', //taken from a URL variable
   'transactionTotal': 0.00,
   'transactionProducts': [{
       'sku': 'FREE',
       'name': 'Free product',
       'price': 0.00,
       'quantity': 1
   }],
   'event': 'transactionComplete'
});
</script>

When the paid version is bought you should be having this:

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}',
   'transactionTotal': 10.00,
   'transactionProducts': [   {
       'sku': 'PAID',
       'name': 'Paid product',
       'price': 10.00,
       'quantity': 1
   }],
   'event': 'transactionComplete'
});
</script>

best regards

Re: Ecommerce setup for multiple products

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Hi Marc,

cheers again. So what you are saying is to add those two scripts before the Tag Manager one like this:

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}',
   'transactionTotal': 0.00,
   'transactionProducts': [{
       'sku': 'FREE',
       'name': 'Free product',
       'price': 0.00,
       'quantity': 1
   },],
   'event': 'transactionComplete'
});
</script>

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}',
   'transactionTotal': 10.00,
   'transactionProducts': [{
       'sku': 'PAID',
       'name': 'Paid product',
       'price': 10.00,
       'quantity': 1
   }],
   'event': 'transactionComplete'
});
</script>

<!-- Google Tag Manager -->



Thanks,
Konstantinos

Re: Ecommerce setup for multiple products

Follower ✭ ✭ ☆
# 8
Follower ✭ ✭ ☆

Hey, 

 

no. Only the one that has actually been bought!

 

So you have either Code one OR Code two. Depending on wich product had been in the Cart.

Everything needs to be variable depending on the customers shopping cart.

 

<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '{{order-id}}',
   'transactionTotal': 0.00,    // or 10 if paid product was bought
   'transactionProducts': [{
       'sku': 'FREE',                // or PAID
       'name': 'Free product',  // or PAID PRODUCT
       'price': 0.00,                  // or 10.00
       'quantity': 1
   },],
   'event': 'transactionComplete'
});
</script>

best regards

Ecommerce setup for multiple products

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

I see, any idea how to set this up ? Any guides, hints etc

Appreciate your help !

Thanks,
Konstantinos

Ecommerce setup for multiple products

Follower ✭ ✭ ☆
# 10
Follower ✭ ✭ ☆

Well that depends on the CMS you are using. There are probably specific guides for your platform available. 

Can't really help you on that part. I'm not a Developer. 

 

Also for some Shop CMS there are already Plugins available that will do it for you.

Only recommendation i can give you is to read this article: https://www.simoahava.com/analytics/ecommerce-tips-google-tag-manager/

 

best regards

Marc