-
AuthorPosts
-
November 27, 2019 at 11:07 pm #1160823
Hi,
I am trying to add google tag manager, but it seems like I can only add the <head> script in the “google analytics tracking code” box.
Where do I add/paste the <body> script? I.e this script:<!– Google Tag Manager (noscript) –>
<noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-M9R8TKM”
height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
<!– End Google Tag Manager (noscript) –>Thank you in advance!
BR,
EmmaNovember 29, 2019 at 11:40 pm #1161402Hey Emmasfm,
You will need to do this with code, as we do not have an option to add code inside body through our Theme Options.
Best regards,
BasilisFebruary 13, 2020 at 11:35 am #1184108I have the same problem with Emmasfm.
Here are GTM script:
– 1st Script: I copy a header.php from the Enfold into the child theme. And then, I paste the 1st script into between the <head>…..</head>
– 2nd script: I paste after the <body> tagBut when I check the status of Google Assistant Extension, the yellow color before the Google Tag Manager.
The yellow color means that at least one Google Tag has a minor issue and the issue should be addressed, otherwise you might face some tracking discrepancies.
How can I fix it? (You can see more detail in the private content)Enfold should have an article guide everyone about Google Tag Manager, I search any available can’t solve the problem.
February 13, 2020 at 10:04 pm #1184319Hi ezvisa,
Please have a look at the following thread:
https://kriesi.at/support/topic/google-tag-manager-6/If you need further assistance please let us know.
Best regards,
VictoriaFebruary 14, 2020 at 4:49 am #1184372Victoria, Ismael mention about using “wp_header” for put script into header and “wp_footer” for footer.
But can you write full code for me? Because I have lacked the skill in coding.
I very much appreciate that!February 15, 2020 at 7:29 am #1184677Hi ezvisa,
Please post the full code you are looking to add to your site and where it should go and, we’ll give you some functions to use.
Best regards,
RikardJuly 20, 2023 at 12:12 pm #1413830Enfold Child > functions.php
add these lines and change the GTM-Code to your Code.
/**
* Google Tag Manager Head Script
*/
function add_custom_gtm(){
?>
<!– 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-XXXXXXX’);</script>
<!– End Google Tag Manager –>
<?php
}
add_action(‘wp_head’, ‘add_custom_gtm’);
/**
* Google Tag Manager Body Script
*/
function google_tag_manager_body_code() { ?>
<!– Google Tag Manager (noscript) –>
<noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX”
height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
<!– End Google Tag Manager (noscript) –>
<?php }
add_action( ‘ava_after_body_opening_tag’, ‘google_tag_manager_body_code’, 1);July 21, 2023 at 5:07 am #1413902Hi xxtita,
Thanks for sharing the code.
For further information you can check our documentation: https://kriesi.at/documentation/enfold/google-analytics/Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.