[Support request] Google Tag Manager Speed Problem

Home Forums Support [Support request] Google Tag Manager Speed Problem

Home Forums Support Google Tag Manager Speed Problem

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1985043
    Giovanni

    Hi all,

    Tag Manager in speed tests slows the site down by 1.5 seconds.
    Is there a way through the hook to make it load as the last element on the page?

    IN WP BODY OPEN:

    <!– Google Tag Manager (noscript) –>
    <noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-MBNLJLC&#8221;
    height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
    <!– End Google Tag Manager (noscript) –>

    IN WP HEAD:

    <!– Google Tag Manager –>
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’:
    new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src=
    https://www.googletagmanager.com/gtm.js?id=’+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,’script’,’dataLayer’,’GTM-MBNLJLC’);</script>
    <!– End Google Tag Manager –>

    #1985611
    Leo
    Staff
    Customer Support

    Hi there,

    Not sure if I understand. Google instructs the code to be added in wp_head and wp_body_open and both of those hooks are at the start of the page:
    https://github.com/tomusborne/generatepress/blob/master/header.php#L17
    https://github.com/tomusborne/generatepress/blob/master/header.php#L27

    There isn’t a way to change that.

    #1986356
    Giovanni

    Hi Leo,

    google tag manager loads when I open each of my site pages. This consumes energy and speed making me lose 1.5 seconds in tests.

    I would like to understand if there is a way to move the google tag manager loading last

    #1986443
    David
    Staff
    Customer Support

    Deferring Tag Manger scripts can be a pain and not recommended by Google as it can result in missing analytics.
    The alternative method is to load them locally, and there are plugins that can do this.

    Theres the PerfMatters plugin. And the CAOS plugin on wp.org.

    #1989273
    Giovanni

    thanks David

    #1989681
    David
    Staff
    Customer Support

    You’re welcome

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