Reply
Highlighted
Regular Visitor
Posts: 25
Registered: ‎12-20-2016

Google Optimize

Hi All,

This thread seems to be closed as I can't post there, but I think the question of setup of Optimize itself has not been closed. We're going to deal with this setup more and more often, I would say. So here's my response, and please feel free to correct me or list better solutions ;)

I would say a better still way is to include the whole modified GA snippet in Tealium sync tag (accessible via 'Manage Templates'). This way it loads sooner, which is so important to speed up loading of variations and reduce flickering.

 2017-12-28_10h34_22.png

 

Still, the primary issue is the hiding snippet. It requires a style element, which cannot be pasted. I have added the following to the utag.sync template:


//create data layer var dataLayer = dataLayer || []; //create style for hiding element var css = '.async-hide { opacity: 0 !important} ', head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); style.type = 'text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }; //hiding snippet (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; })(window,document.documentElement,'async-hide','dataLayer',4000, {'GTM-MF5BFM5':true}); head.appendChild(style);

It seems to work, but if anyone has a better suggestion or can improve the hiding snippet, please let me know.

Best regards,

Florian