[Branda] Google Optimize – add field on Branda's UA Tracking ID page, to insert GTM Optimize

I was going through Analytics & Tag Manager… and started playing with Google Optimize, and noticed that adding in the Optimize GTM code can be done with a very small Universal Analytics code modification.

Please see below, and note the small “, { ‘optimize_id’: ‘GTM-XXXXXXX’}” code insert.
(the following is a direct copy/paste from how to use the Google Optimize code snippet)


Optimize Snippet Installation
Optimize is installed by adding a small snippet of code to your website to display Optimize experiences (tests and personalizations) to your visitors. Learn more .
If you use Global Site Tag (gtag.js) to deploy Google Analytics, simply add the Optimize snippet to the config line.

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1"></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-XXXXXXXX-1', {'optimize_id': 'GTM-XXXXXXX'});

Paste the updated tag at the top of the <HEAD> on every web page you wish to personalize and test.
– If you use Google Tag Manager (GTM), learn more about how to use it with Optimize.
– If you use Universal Analytics (analytics.js), learn more about how to use it with Optimize.
– Optional: If you encounter page flickering issues you can install the anti-flicker snippet .

  • splaquet
    • The Incredible Code Injector

    I’d like to see an empty field in Branda, where an admin could add their Google Optimize code.

    as noted in my original message, there’s very little extra code needed to insert the Optimize tag into the current Analytics script.

    so, maybe it’s something like this:
    – (checkbox) If you would like to add your Google Optimize Tag to your Analytics, please select here
    – {then some magic happens in the backend, inserting this code into the current Analytics script:
    , { ‘optimize_id’: ‘GTM-XXXXXXX’}
    – and a new field appears, where an admin would be able to add/insert their ‘GTM-XXXXXXX’ tag into the field (maybe with the GTM-XXXXXXX in the light grey placeholder color, so admins/users would know the required format)
    – and then an option to save

    does that make more sense?

  • Kasia Swiderska
    • Support nomad

    Hello splaquet ,

    Yes, it does make sense, however, that field is not just for the Google Analytics code. It’s for tracking code in general. So it could be Matomo Tracking Code. Then having those specific options there would be too much and not really needed.
    I think something like that would be better for the Beehive plugin that is dedicated specifically for Google Analytics.
    I will ping the Beehive team about your request.

    kind regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.