Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Google Tag Manager Integration: How to add multiple containers per App environment?

I completed the integration of the latest Google Tag Manager (v5) for iOS together with Firebase (https://developers.google.com/tag-manager/ios/v5/). The big change here is that the default container file is not binary anymore, it is plain JSON.

The integration requires that you have a folder (not group!) with the name "container" inside your 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 GTM requires the folder on root level and with the exact name "container"

Does anybody have an idea how this can be solved?

Thanks, Fahim

enter image description here

like image 669
Fahim Avatar asked Oct 24 '16 09:10

Fahim


2 Answers

You should be able to configure an XCode "run script" build step that clears the container directory and copies the correct container into place.

like image 108
Eric Burley Avatar answered Sep 27 '22 23:09

Eric Burley


Sample Run Script (if somebody has the same issue):

rm -vf ${SRCROOT}/root_folder/container/*
cp "${SRCROOT}/root_folder/target/test/GTM-XXXXX.json" "${SRCROOT}/root_folder/container/"

It is important that this copy job is done at first within Build Phases, otherwise some other precompiling stuff of GTM does not recognize the container.

like image 45
Fahim Avatar answered Sep 27 '22 23:09

Fahim