I am trying to put 2 containers in my XCode project (1 for STAGING and another for PROD). Is this possible in Google Tag Manager? If so, how do I achieve it?
You can use build script to copy necessary file to yourProjectName/container folder before run.
Go to Project -> Targets -> YourTarget -> Build Phases, add New Run Script Phase, add script like this:
rm -vf ${SRCROOT}/container/*
if [ "${CONFIGURATION}" == "Release" ]; then
cp -v "${SRCROOT}/App/Analytics/GoogleTagManager/XXXXXXX_release.json" "${SRCROOT}/container/GTM-XXXXXXX.json"
elif [ "${CONFIGURATION}" == "Debug" ]; then
cp -v "${SRCROOT}/App/Analytics/GoogleTagManager/YYYYYYY_debug.json" "${SRCROOT}/container/GTM-YYYYYYY.json"
fi
Folder yourProjectName/container will be cleared every run, and debug or release container .json file will be copied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With