Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Our development process is that we have local dev, live dev and the production. We can remove the tracking code in dev environments. But, without having to remember to add and take away tracking code within the module on every site every time we restore data, how do we specifically track the live domain and not dev's?
I would assume that we use a single domain but this tracks code from the the live development environment as well as production.
So should we use "One domain with multiple subdomains" or "Multiple top-level domains"
...and how to make sure we capture WWW and non-WWW.
Comments
Comment #1
hass CreditAttribution: hass commentedPrepare a drush script and run it on dev.
Comment #2
crutch CreditAttribution: crutch commentedsounds easy enough but drush is not part of our process at this time
Comment #3
crutch CreditAttribution: crutch commentedComment #4
hass CreditAttribution: hass commentedThan you need to change your process.
Comment #5
crutch CreditAttribution: crutch commentedIf were up to me I would. Guess will get no help on this one.
Comment #6
ultimateboy CreditAttribution: ultimateboy commentedcrutch, the easiest way is to override the variables used by this module in settings.php with something along the following lines:
You can either specify a different ga account or leave it blank which should stop it from firing.
You'll need to wrap this in a condition, but that's a pretty common thing to when working with multiple environments. There are two common methods, the first is to define an apache environment variable which you can use in a switch statement to change various configurations depending on environment (Pantheon does this for example). The second is to include a settings.local.php file at the end of your settings.php and include environment specific configurations there. This then opens up the possibility of checking your settings.php in to git, free of your database credentials of course, which are then re-located (along with other configs such as google analytics) to your settings.local.php.
Of course, a drush script and a scripted deployment process could do this as well, but thought I'd share my methods for achieving this.
Food for thought.
Comment #7
crutch CreditAttribution: crutch commentedthanks UB! That gives me some goods to move forward here.
Comment #9
interestingaftermath CreditAttribution: interestingaftermath commentedFollowing the example of the solution in #6, I wrote this little one liner that you can use from command prompt. Just cd into the default directory and run this. It will add the line compatible with Drupal 7 to the end of the settings.php file.
Comment #10
kopeboy CreditAttribution: kopeboy commentedThe configuration at the Pantheon page you linked is a bit different than in comment #6
They use conf instead of vars, like this:
Should I use conf or vars now?
Some documentation (on the module page?) would be useful..
Comment #11
hass CreditAttribution: hass commented$conf
is correct in settings.php in all releases.Or you better use
drush
and delete the variable in DEV.I hope this gives you more ideas what typically need to be changed when moving live systems to DEV.
Comment #13
ExTexan CreditAttribution: ExTexan commentedIn case anyone else finds this issue, but are needing the syntax for D8, this worked for us...
Comment #14
newaytech CreditAttribution: newaytech commenteddoes anyone know the syntax here for setting two accounts in config? Wanting to run UA and GA4 at the same time?