GTM Setup for Multiple Environments in iOS

Shalabh Agarwal Aug 20th, 2019

iOS | How to setup Google Tag Manager for multiple environments The integration requires that we have a folder (not group!) with the name “container” inside app workspace. Within this folder the container file should be located. This raises my issue: We have two different GTM Containers, one for the testing/development app and one for production.

  • By using a folder it is not possible for me to add a different container file and set target references.
  • I can not create an additional folder since google tag manager environments requires the folder on root level and with the exact name “container”.

We should be able to configure an XCode “run script” build step that clears the container directory and copies the correct container into place. Go through following steps to resolve this issue –

    • For multiple GTM container JSON file (say Prod and QA), c Copy the downloaded json file into a folder called ‘container’ in your XCode project root directory
    • Click on ‘Build Phase’, add a new Run Script, and paste the code in the screenshot below or paste the following into your new script area;
      rm -vf ${SRCROOT}/container/* if [ “${CONFIGURATION}” = “Release” ]; then #echo Do something really release-like cp “${SRCROOT}/GTMFile/GTM-your file name.json” “${SRCROOT}/container/” else cp “${SRCROOT}/GTMFile/GTM-your file name.json” “${SRCROOT}/container/” fi

 

And it’s done. Build and run, you will have single json for the respective configuration..

Shalabh Agarwal - Co-founder, Enveu
Shalabh Agarwal is the co-founder of Enveu, one of the fastest-growing App automation and OTT solutions providers. Shalabh oversees the global businesses for Enveu and has been working in the Technology and SaaS space for over 15 years.

Add a Comment

Your email address will not be published. Required fields are marked *

Looking for Streaming Solutions?

  • Go-Live on 12+ platforms
  • Zero Revenue Share
  • Multiple Monetization Models
  • 50+ Integrations

get a demo today

Take control of your digital media strategy.
Contact us for a no-obligation demo of the Experience
Cloud, tailor-made for you!

    By Continuing, you agree to our Terms & Conditions and Privacy Policy