Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLANET-7625: Move Google Tag Manager scripts away from Twig templates #2503

Open
wants to merge 39 commits into
base: PLANET-7625_move-scripts-from-twig-templates
Choose a base branch
from

Conversation

mardelnet
Copy link
Contributor

@mardelnet mardelnet commented Jan 17, 2025

Summary

This PR removes Google Tag Manager scripts from the Twig templates and enqueue them correctly using WordPress methods and Webpack. It's the continuation of #2502


Ref: https://jira.greenpeace.org/browse/PLANET-7625

Testing

Check that Google Tag Manager keeps working as expected.


Notes

  1. I'm not quite happy with this implementation since it depends on firing the custom action pass_gtm_data every time the function Timber::render is called. I've tried to hook that last function to fire the custom action without the need to call it every time that Timber::render is also called, but I couldn't. Apparently, there is no such a hook. Please, let me know your thoughts and new ideas.
  2. I found there are PHP files including JS scripts instead of enqueuing them using WordPress methods. Perhaps, we could extend the class I've created and fix that in another ticket/PR.

cc: @comzeradd

@mardelnet mardelnet self-assigned this Jan 17, 2025
@mardelnet mardelnet changed the title PLANET-7625: Move Google Tag Manafer scripts away from Twig templates PLANET-7625: Move Google Tag Manager scripts away from Twig templates Jan 17, 2025
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 17, 2025
/unhold b6809ac3-7eaf-41df-a1bc-e4ada37c334a
@mardelnet mardelnet force-pushed the PLANET-7625_move-gtm-scripts-from-twig-templates branch from cd17b61 to b01174e Compare January 17, 2025 11:30
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 17, 2025
/unhold fecb2cc2-3ac9-49a0-bc88-1b49baeb5c5b
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 17, 2025
/unhold 58d37d43-f674-4b03-9df8-c67fd33b7099
@mardelnet mardelnet force-pushed the PLANET-7625_move-gtm-scripts-from-twig-templates branch from 6fcf53e to 9d4b5a4 Compare January 17, 2025 12:19
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 17, 2025
/unhold 00c37e0f-574e-46b6-bff2-2410ad8f0381
@mardelnet mardelnet force-pushed the PLANET-7625_move-gtm-scripts-from-twig-templates branch from 9d4b5a4 to 9a4eab7 Compare January 17, 2025 14:09
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 17, 2025
/unhold f8f6386a-fa3b-43fb-a165-e0224d836c36
@planet-4
Copy link
Contributor

planet-4 commented Jan 17, 2025

Test instance is ready 🚀

🌑 nix | admin | blocks report | CircleCI | composer-local.json

⌚ 2025.01.21 15:33:52

planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 20, 2025
/unhold d82fca69-1e5a-41ee-b5e0-786fa7980b7d
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 20, 2025
/unhold 74295523-8d4b-4d7f-9080-075d1261d4f7
@mardelnet mardelnet changed the base branch from PLANET-7625_move-scripts-from-twig-templates to demo/wp-block January 21, 2025 10:48
@mardelnet mardelnet changed the base branch from demo/wp-block to PLANET-7625_move-scripts-from-twig-templates January 21, 2025 10:48
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 21, 2025
/unhold 2f1b23c2-44c9-4865-ac3e-655d7944b1c7
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 21, 2025
/unhold 690fb2b7-dfa6-41e6-a355-37c7f36a4f42
@mardelnet mardelnet marked this pull request as ready for review January 21, 2025 11:19
planet-4 added a commit to greenpeace/planet4-test-nix that referenced this pull request Jan 21, 2025
/unhold a9656fc9-adb2-44a2-b2fb-0cffd31e5c42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants