Google Tag Manager
This topic contains 12 replies, has 4 voices, and was last updated by Paolo 6 years, 4 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: Google Tag Manager
-
AuthorPosts
-
June 28, 2018 at 6:51 pm #436493
Hi guys,
I´m trying to install Google Tag Manager using code snippets. I´m using Supreme Directory
Google Tag Manager instructions are to “Copy the following JavaScript and paste it as close to the opening <head> tag as possible on every page of your website”
I´m using this one for the header part:
(add_action( ‘wp_head’, function () { ?>)And then “Copy the following snippet and paste it immediately after the opening <body> tag on every page of your website”
And I don´t know what to use there, I tried:
add_action( ‘wp_footer’, function () { ?>)
add_action( ‘geodir_details_main_content’, function () { ?>
add_action( ‘dt_after_header’, function () { ?>
add_action( ‘body_class’, function () { ?>But none of those worked 🙂
Could you help me with the right snippet please?
Thank youuu!!
June 28, 2018 at 7:21 pm #436503Try adding it to
Geodirectory – Design – Scripts – Header script code
June 28, 2018 at 9:35 pm #436519Thanks Alex, both parts?
To implement Google Tag Manager on your website:
Copy the following JavaScript and paste it as close to the opening <head> tag as possible on every page of your website, replacing GTM-XXXX with your container ID:
<!– 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-XXXX’);</script>
<!– End Google Tag Manager –>Copy the following snippet and paste it immediately after the opening <body> tag on every page of your website, replacing GTM-XXXX with your container ID:
<!– Google Tag Manager (noscript) –>
<noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-XXXX”
height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
<!– End Google Tag Manager (noscript) –>June 28, 2018 at 9:36 pm #436520Should I add the add_action part?
June 28, 2018 at 9:58 pm #436521If I just copu and paste both of them it doesn´t work.
I guess the header part is ok, but not the body
Greetings
June 28, 2018 at 10:18 pm #436522can you help with the right snippet?
June 29, 2018 at 1:20 am #436529Hi Tania,
Could you share your WP admin access in private reply so that we could check your entry? Also, what’s your correct “GTM-XXXX” ID?
June 29, 2018 at 4:42 am #436538This reply has been marked as private.June 29, 2018 at 7:51 am #436560This is for JS only: Geodirectory – Design – Scripts – Header script code
PHP Snippets are added with the Code Snippets plugin.
If it is only some header JS you can paste it into the field at:
Geodirectory – Design – Scripts – Header script code
June 29, 2018 at 2:10 pm #436604Thank you Alex, that´s exactly where I need help, inserting the second part after the <body> tag without touching the parent theme.
This is what I need to insert:
Copy the following snippet and paste it immediately after the opening <body> tag on every page of your website, replacing GTM-XXXX with your container ID:
<!– Google Tag Manager (noscript) –>
<noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-XXXX”
height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
<!– End Google Tag Manager (noscript) –>June 29, 2018 at 4:59 pm #436632did you try to add it in Geodirectory – Design – Scripts > Footer scripts?
Let us know,
Thanks
June 29, 2018 at 7:09 pm #436671Paolo, it did 🙂
I didn´t wanted to place it there since Google recommends to do it after body tag and not footer, to be more accurate, but it seems to be working.
If there´s a way to do it after the body it would be awesome, if not, this can work for now
Thank you!
June 29, 2018 at 10:07 pm #436697Hi Tania,
This is the typical structure of a WP theme page (simplified)
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Your Website</title> </head> <body> <header> <nav> <ul> <li>Your menu</li> </ul> </nav> </header> <section> <article> <header> <h2>Article title</h2> <p>Posted on <time datetime="2009-09-04T16:31:24+02:00">September 4th 2009</time> by <a href="#">Writer</a> - <a href="#comments">6 comments</a></p> </header> <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p> </article> <article> <header> <h2>Article title</h2> <p>Posted on <time datetime="2009-09-04T16:31:24+02:00">September 4th 2009</time> by <a href="#">Writer</a> - <a href="#comments">6 comments</a></p> </header> <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p> </article> </section> <aside> <h2>About section</h2> <p>Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> </aside> <footer> <p>Copyright 2009 Your name</p> </footer> </body> </html>
While the header if before the Body tag, the Footer is after the body opening tag.
So you it is perfectly placed to work correctly.
Thanks
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket