[Support request] Question about Implementing GTM

Home Forums Support [Support request] Question about Implementing GTM

Home Forums Support Question about Implementing GTM

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1651518
    Sebastian

    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

    #1651633
    David
    Staff
    Customer Support

    Hi there,

    theres no difference between either method.

    #1784709
    Margaret

    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

    #1784780
    David
    Staff
    Customer Support

    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.

    #1789451
    Margaret

    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?

    #1789525
    David
    Staff
    Customer Support

    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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.