Rich-text Reply

Pushing order value amount to Optimizely through GTMs dataLayer

himynameisivo 02-16-16
Accepted Solution

Pushing order value amount to Optimizely through GTMs dataLayer

[ Edited ]

Hi guys,

 

I'm looking into "getting" as much as I can from Optimizely and digging beyond simple conversion/drop off rates numbers. Hence, I would like to push some information (in this case order value) to the platform.

 

So, from what I've read this should be implemented on the success page (where we have this information) and that should be pushing this information to Optimizely.

 

<script>
  window.optimizely = window.optimizely || [];
  window.optimizely.push(['trackEvent', 'Revenue', {'revenue': variable}]);
</script>

 

That 'order' - variable is already something we push to our GTM dataLayer. My question is could I just implement this code in GTM to fire on the thank you page and use the GTM {{variable}} syntax to push this to Optimizely? So, smth like that (using our GTM variable)

<script>
  window.optimizely = window.optimizely || [];
  window.optimizely.push(['trackEvent', 'Revenue', {'revenue': {{net_price}}}]);
</script>

Following that logic, could I be pushing other GTM variables to Optimizely defined custom goals?

 

I hope the question is clear enough (first time really digging into that field). 

 

best,

Ivo

 

Performance Marketing Manager @ Blacklane
Founder @ Stereofox

Re: Pushing order value amount to Optimizely through GTMs dataLayer

Hi Ivo,

Thanks for your question! Pushing data to Optimizely this way is a good way to do that. Please make sure you're using the "Custom HTML Tag" in GTM, and that the {{net_price}} part in your script gets replaced by the revenue value in cents. Then, Optimizely should pick this up and send it to the backend to be counted on the results page.

You can also fire custom goal events to Optimizely this way, but instead use the code for that:

<script>
  window.optimizely = window.optimizely || [];
  window.optimizely.push(['trackEvent', 'eventName');
</script>


Please replace eventName with the name of the custom event, so Optimizely will know which goal this conversion belongs to. See this article for more information on custom goal events.

 

Does this answer your question?

Best, Nils

Re: Pushing order value amount to Optimizely through GTMs dataLayer

Hi Nils,

Thanks a lot for the thorough answer - currently waiting on the snippet implementation on that page and as soon as this is done, will follow your advice and let you know if everything worked out accordingly.

best,
Ivo
Performance Marketing Manager @ Blacklane
Founder @ Stereofox

Re: Pushing order value amount to Optimizely through GTMs dataLayer

[ Edited ]

Hi Nils,

I got the Optimizely snipet on our successful booking page and am about to use the GTM as a solution to push this variable. Then, I realized that in GTM the {{net_price}} variable is not in cents, but it's rather just a numerical value and also we have 3 currencies - EUR/USD/GBP.

Does this mean I should write a few lines in that script which convert the USD/GBP net price value to EUR and then multiply * 100 and then pass it to Optimizely?

<script>
  window.optimizely = window.optimizely || [];
  var currency == {{currency}};
  if ( currency == 'GBP') {
  	var net_price == {{net_price}} / 0.80;
  }
  if ( currency == 'USD') {
  	var net_price == {{net_price}} / 1.11;
  }
  var priceInCents = {{net_price}} * 100 ;
  window.optimizely.push(['trackEvent', 'Revenue', {'revenue': priceInCents }]);
</script>
Performance Marketing Manager @ Blacklane
Founder @ Stereofox

Re: Pushing order value amount to Optimizely through GTMs dataLayer

Hi Ivo,

 

Optimizely doesn't convert USD/GBP net price value, because there are different ways of doing this that might all be 'correct' for different businesses. It looks like you're doing the right thing. One thing I'd include is to round the priceInCents before sending it off, e.g. by using the JavaScript round()-function.

 

Best,

Nils

Re: Pushing order value amount to Optimizely through GTMs dataLayer

Hi Nils,

 

Just dropping a reply to confirm it's all working perfectly and to leave the final code I was using in case someone in the future needs to use/modify it.

 

Thx for the Math.round tip!

 

<script>
window.optimizely = window.optimizely || [];
var currency = {{currency}};
var net_price = {{net_price}};
if ( currency == 'GBP') {
 	net_price = net_price  / 0.78;
}
if ( currency == 'USD') {
 	net_price = net_price  / 1.11;
}
var valueInCents = Math.round(net_price * 100);
window.optimizely.push(['trackEvent', 'Revenue', {'revenue': valueInCents }]);
</script>

best,

Ivo

Performance Marketing Manager @ Blacklane
Founder @ Stereofox

Re: Pushing order value amount to Optimizely through GTMs dataLayer

I'm glad it helped you Ivo! Please note that with changing currencies you could also have a look at using an API for that, if that'd suit your needs. See for example; https://www.google.nl/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=javascript%20conversion%...

Best,

Re: Pushing order value amount to Optimizely through GTMs dataLayer

Always a step ahead, Nils! Hats off, sir.

Was going to take things further and look into API integration, so that's definitely helpful. I guess for now it would work, but obviously if we're striving to perfect and automate things, such library is a must Smiley Happy

best,
Performance Marketing Manager @ Blacklane
Founder @ Stereofox