Note: If you use the global site tag (gtag.js), follow these instructions instead.
If you want to deploy Optimize with Google Tag Manager, follow the instructions below. If you use another tag management system (TMS), follow their instructions to add Optimize to your existing Google Analytics tag.
Custom tracker settings
Users of custom tracker settings must use the shared Google Analytics Settings variable in Tag Manager and Analytics to ensure that all tracker settings match between tags.
Step 1: Collect the necessary information
You need the following information to install Optimize:
- Your Analytics tracking ID.
- Your Optimize container ID.
- Confirm that your Tag Manager and Analytics tracker settings use the shared Google Analytics Settings variable.
Step 2: Configure Optimize in Tag Manager
Once you have the information above, follow these steps to configure Optimize in Tag Manager:
- Sign in to Tag Manager and select an account.
- Click Tags > New.
- Click Tag Configuration > Google Optimize.
- Enter your Optimize container ID.
- Select a Google Analytics Settings variable.
- Click Save and save the tag without triggers.
- Open the Analytics page view tag for the Analytics property linked to your Optimize container.
- Click Tag Configuration > Advanced Settings > Tag Sequencing.
- Check the box to fire a tag before this tag fires. Under the Setup Tag heading, click the menu and select the desired Optimize tag.
- Configure the Optimize tag to fire once per page, then save it.
- Publish your Tag Manager container for the changes to take effect.
Learn more in the Tag Setup Guide for Optimize in the Tag Manager help center.
Snippet placement best practices
For optimal performance place your Tag Manager tag at the very top of the
<head> of every page you wish to optimize.
The only items that should appear above the global site tag are:
- Data layer initialization. Note: the dataLayer variable should never be reassigned after the page-hiding snippet (when used).
- The optional page-hiding snippet which can be used to avoid flicker.