For a long time now I have been setting the Web Property ID as blank via settings.php or similar methods so that tracking doesn't occur on any environment other than my production environment.
Recently I released a module, Contextual variables, that allows for variables defined by the Variable module to be defined via Context, allowing me to theoretically do what I used to do via settings.php via UI instead.
I was happy to see that the Google Analytics module had declared the Web Property ID, but unfortunately I found that it required a value and validated the value, which meant I couldn't set it to blank to prevent tracking to occur.
While I understand that this may not exactly be something you would want to encourage, it is something I would think would be extremely useful.
Patch attached in comment #1.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | variable_empty_id-1964052-15.patch | 3.26 KB | deciphered |
| #1 | variable_empty_id-1964052-1.patch | 1.57 KB | deciphered |
Comments
Comment #1
decipheredComment #2
hass commentedI suggest to set the value via drush in DEV. You need to change a lot of settings in dev and this is just one. We already have domain and i18n support. Not validating the UA code sounds like no option at all to me as this caused a LOT of support issues in past.
Comment #3
hass commentedHm... Should take a look to the patch first. Allowing an empty value sound useful to me, but removing validation completly not.
Comment #4
decipheredHass,
This doesn't remove validation completely, what it does is not return false if the value is left empty, which as you say is useful. If the value is not empty, validation will work as normal.
Happy to modify the patch in anyway you see fit, but as it is I think it should satisfy all your potential concerns.
Comment #5
hass commentedComment #6
hass commented#1: variable_empty_id-1964052-1.patch queued for re-testing.
Comment #7
decipheredI get a feeling that the test isn't going to be processed :|
Comment #8
hass commentedSince variable module may not exists in D8 moving back to D7. But why are we only changing this on variables form and not also on admin form?
Comment #9
decipheredI'm happy to change this on the standard form as well, will update the patch as soon as I have a chance.
Comment #10
hass commentedAny news?
Comment #11
decipheredHaven't had a chance yet, my priorities change from day to day based on the client work I am currently doing.
Comment #12
philyOr use a fake ID like UA-1234567-89 (I hope it's fake ;-)
Comment #13
hass commentedI typically use
UA-1234-1as it's used in references and docs. It allows a test.Comment #14
hass commentedNo update for an extended period of time. Closing because of inactivity.
Comment #15
decipheredRe-rolled and added change from #8.
Comment #18
decipheredRe-roll
Comment #19
decipheredStrike that last re-roll, forgot I'd already re-rolled :|
Comment #20
hass commentedBroken re-role
Comment #21
decipheredThe reroll is fine, it's just unnecessary as the previous patch is identical. Both apply and both work.
Comment #22
hass commentedNot identical. Review the patch, please.
Comment #23
hass commentedFault
Comment #24
hass commentedNo update for an extended period of time. Closing because of inactivity.
Comment #25
decipheredReopening. There is at least one working patch in this issue as well as working code, it would be a shame to lose it due to confusion.
I will attempt a re-roll this evening.
Comment #26
hass commentedComment #27
deciphered@hass Am I correct in your changing of branch to imply that you want the work done to 8.x-2.x before backporting to 7.x-2.x? If so, it may take longer as it's no longer a simple re-roll, however if that is the desired process I have no issue with that as I will be implementing the same workflow in my modules soon enough.
Comment #28
hass commentedYes, GA D8 is ready for prime time. You can rerole, but it also requires a D8 patch first.
Additionally I'm still not sure how we can solve the usability issue. I'd like to have form validation and show the red star to imply this is a must value. If I only think about the number of issues we had before I introduced the validation/requirement compared to today I'm still not convinced this helps users except for edge cases. I wish we could do some comparison to core or other modules how they handle such form settings.
It is sooo easy to delete this variable via drush...
Comment #29
decipheredOk, so maybe we can re-think this, my needs are to suppress Google Analytics when in specific environments, and while this solution works perfectly, if you are not happy with the approach then it's going to cost me more time than I have.
Instead, how about an 'enabled' variable of some sort, or a hook_suppress() approach (preferably in conjunction with a variable).
Thoughts?
As far as the 'delete via drush' approach, that is too reliant on human interaction for my likes, I prefer to keep things as automated as possible.
Comment #30
hass commentedI always put the drush commands in a script. This easily allows me to backup live systems, restore them scripted on test/staging and then run a bunch of drush commands to correct all variables that need to be changed to the system.
These are at least:
How do you change the paths from production to dev without drush?
I do not like to waste both of our time, but I think we lose more than we win. At least 1-2 useless support cases per week is what I will get here.
Comment #31
decipheredI use the Contextual variables module that I wrote which allows any variable that's been exposed to the Variables module to be modified/set as a Context reaction, in conjunction with other modules that determine what environment I am currently in.
Comment #32
japerryWith the sunset of legacy google analytics, the 8.x-2.x module is now unsupported. If this is still an issue with the 4.x version, please file a new issue in the queue.