While working with google_tag module in a recent project, I faced few things which required enhancing the module.

Issues are :
1) Server to Server movement : Initially we used 7.x-1.2 version of the module and there if you moved the project from one server to another ( like Dev to Stage ) and if both env is supposed to have different GTM id, the GTM snippets were not getting automatically updated/regenerated. Someone had to login to the backend and submit the GTM config form to regenerate the files with new GTM tag.

In latest version of the module, as I see, we do have a Cron hook written to do that, but again it does not seem to make any checking if the files are there or not and on each cron run, it rewrites the files.
2) An alert notification system: A notification system embedded for any GTM failure.

It can be released as a new version considering the major changes.

Comments

pbose_drupal created an issue. See original summary.

solotandem’s picture

Assigned: pbose_drupal » Unassigned

The issue summary is non-specific. I take it you have tried the 1.3 release (as the issue is marked for this release)? Can you quantify conditions on which you have observed a lack of the snippet files? Can you determine whether it is related to such things as hosting provider, file system, use of varnish?

A suggestion on another issue was to simply check for the files on each page request and, if missing, create them from the configuration.

pbose_drupal’s picture

In standard development lifecycle, we have Dev/Stage/Prod servers and each environment can have separate GTM ID. This is atleast true for Prod and non-prod environments. So when the module is setup for one environment and the site gets pushed ( code, file system, db ) to another environment, the snippet files also gets pushed and they contain improper GTM ID. So someone has to recreate the files to make them ready for this environment.
Checking the files on each page request may be a overkill. Instead the patch we have written checks for the proper GTM ID in the snippet files when ever site cache is cleared.
The patch also contains the Alert notification mechanism I mentioned earlier.

solotandem’s picture

My response to your various statements in issue summary and comment.

Comment: The 1.3 release implements hook_cron to recreate the snippet files, but it does not check whether the files are there or not and, on each cron run it rewrites the files.

Reply: How would the module know whether the files need to be recreated short of doing so, comparing contents, and then deciding to overwrite? Why not simply write each time?

Comment: When the module is setup for one environment and the site gets pushed ( code, file system, db ) to another environment, the snippet files also get pushed and they contain improper GTM ID. So someone has to recreate the files to make them ready for this environment. The patch we have written checks for the proper GTM ID in the snippet files whenever site cache is cleared.

Reply: Would you have me believe the GTM ID is the only configurable item that differs by environment on your sites? What about the Google Analytics ID? If not, how do you handle the other environment-specific items? What does your patch code check against to determine whether the correct GTM ID is included in the snippet files? Is it reading from settings.php file [or equivalent]? Why not use the same mechanism or set the GTM ID in the settings.php file with code that recognizes the environment? On hook_cron, the snippet files will be recreated using the correct ID.

Surely you are not suggesting this module play a part to manage your environments.