Install Google Optimize on Your Website
This step is essential, but the way you do it depends on how you currently have your Google Analytics tracking set up. I will introduce two common approaches respectively. You can choose either one of them although I encourage you to try.
1. Install Optimize with optimize.js
If you have manually entered your Google Analytics tracking code into your header (or another part of your site), which is exactly the same as discussed at section 2.1 of my another article, Install Google Analytics on your Website, all you need to do is copy and paste a new line of code into it as instructed:
1. Go to the container page of your Optimize account.
2. Add the following code to the top of the “<head>” tag on ALL the blog page you wish to optimize and click save button.
2. Install Optimize with Google Tag Manager (GTM)
If you prefer to use Google Tag Manager approach, you can do as the following instructions for configuring the Optimize tag.
1. Collect the following necessary information:
A. Your Analytics tracking ID.
B. Your Optimize container ID.
C. Confirm that your Tag Manager and Analytics tracker settings use the shared Google Analytics Settings variable, i.e., have Google Analytics installed via Google Tag Manager
2. Copy your Optimize container ID somewhere for future use
You can find it at Container setup > Container information in Optimize.
3. Configure Optimize in Tag Manager
A. Sign in to Google Tag Manager and select an account.
B. Click on “New Tag”. Or click Tags > New.
C. Click Tag Configuration > Google Optimize
- if you have installed Google Analytics with Google Tag Manager in the past,
you should have your Google Analytics Tracking code variable set up (see step B of part 2 at subsection 2.2 in my post, Install Google Analytics on your Website). Select it in the Google Analytics settings;
- if not,
click on “Select Settings Variable” > New Variable and add your Tracking ID (UA-XXXXXXXXX-1) that you can find in Google Analytics > Admin > Property > Property Settings > Tracking ID, which is exactly the same as process at the installation of Google Analytics via GTM.
F. Click Save and save the tag without triggers.
G. Give the tag a name or use the default one.
H. Then, you would have two tags: Analytics and Optimize:
Note: You want to fire the Google Optimize Tag before Google Analytics because Google Analytics need Optimize to run before they can track the result of your tests. Typically, it means that Google Analytics relies on the output of Google Optimize. This box basically makes a JavaScript Callback function.
3. Install the Anti-flicker Snippet
<!-- Anti-flicker snippet (recommended) --><style>.async-hide { opacity: 0 !important} </style><script>(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,{'CONTAINER_ID':true});</script>
- Install the anti-flicker snippet after section 1 (Install Optimize with optimize.js), you will finally have:
- Install the anti-flicker snippet after section 2 (Install Optimize with Google Tag Manager (GTM)), you will finally have:














Comments
Post a Comment