Just a simple question here as I'm new to GTM. We have the staging environment at xxx.company.com and the production environment at xxx.com
Both sites use the same source code of course, so the same GTM account and same script.
How can you add scrips via GTM only to the staging website? Make sure that it is working there and then add it to production.
Is it necessary to get the GTM ID from CMS admin so that it will be different for staging and production or it can be done in GTM dashboard.
Thanks!
AFAIK it is recommended to have separate Tags (with the new export/import-feature it's easy to transfer configurations between two containers, or you write an API script to do it).
Having said that it is possible to run scripts only on the staging site - the hostname differs between staging and live, so you can always block a tag from firing on the live site (in v1 of the tag manager this is called "blocking rule", in the current version there is "create exceptions" when you set the firing triggers.
If you don't have a staging site at all you can use the preview mode to test your new tags within the live site - in that case GTM sets a cookie in your browser that indicates to the GTM code to fetch an unpublished version of the container, so you can check a tag within the live site without the general public being affected.