Archived topic
Question about Implementing GTM
5 replies · Started by Sebastian on February 9, 2021
Hello,
I'm About to implement the GTM, so i'm reading the documentation . I know there are two options using hooks or using functions.
My questions is, in terms of webpage speed, and user experience, which method is better or has less impact in the website
Hi there,
theres no difference between either method.
Hello,
In response to Sebastian's question about hooks vs. functions -- Is there anything that the Code Snippets plugin can do, that GeneratePress Elements *can't* do?
- For Google Tag Manager I'm using the "Google Tag Manager for Wordpress" plugin by Thomas Geiger.
- For Microsoft Ads' UET Tag, I'm using Code Snippets.
- To adjust WooCommerce layout, I'm using this php script in Code Snippets (https://wpexplorer-themes.com/total/snippets/move-woocommerce-additional-information/).
I'm wondering if all of that can be consolidated into GeneratePress Elements.
Thanks,
Margaret
Hi there,
WP provides two types of Hooks - one is the Action Hook and the other is the Filter Hook.
GPs Hook Element only provides Action Hooks.
So you can use it for GTM scripts using two hooks:
For inside <header> you use the wp_header hook
For after the opening <body> tag you use the wp_body_open hook
The code you have in code snippets for the woo layout would have to remain in code snippets or added using a Child Theme.
Thank you very much. I'm going to remove the "Google Tag Manager for WordPress" plugin and add the GTM scripts with the hooks above, following these helpful instructions:
https://docs.generatepress.com/article/implement-google-tag-manager/
On Google's "Setup and install Tag Manager" page, there is a message that says:
"To ensure that tags do not fire twice, remove from your code any hardcoded tags that have been migrated to your Tag Manager container."
What does that message mean? After I add the GTM scripts with the hooks above, are there any other steps that need to be taken?
Nothing else in the Theme is required after that.
“To ensure that tags do not fire twice, remove from your code any hardcoded tags that have been migrated to your Tag Manager container.”
Are you migrating from classic Google Analytics to GTM ? As that warning only applies if you're migrating, and your old GA scripts included hard coded tags.