Why Use Gutenify’s Global Code Feature?
- No Theme File Editing: Avoids the need to modify theme files like header.php or functions.php.
- Persistent Across Updates: Ensures your GTM code remains intact even after theme updates.
- Centralized Management: Provides a single location to manage scripts that apply site-wide.
To add your Google Tag Manager (GTM) script using the Global Code feature in the Gutenify WordPress plugin, follow these steps:
Go to Gutenify Global Code Settings:
From your WordPress dashboard, navigate to Gutenify → Setting → Global Code.
Insert GTM Script into the Header:
In the Global Header Code section, paste the first GTM snippet provided by Google Tag Manager. This script should be placed within the <head> tag of your website.
<!-- 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=GTM-XXXXXXX'+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');
</script>
<!-- End Google Tag Manager -->
Insert GTM NoScript into the Body:
In the Global Body Open Code section, paste the second GTM snippet. This <noscript> tag should be placed immediately after the <body> opening tag.
<!-- 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) -->
Note:
Replace GTM-XXXXXXX with your actual GTM container ID.
Save Changes:
After inserting both snippets, click Save to apply the changes.
Verify GTM Installation
After adding the GTM code:
- Use Google Tag Assistant: Install the Google Tag Assistant Chrome extension to verify that GTM is correctly installed on your site.
- Check Source Code: Right-click on your website, select “View Page Source,” and ensure both GTM snippets are present in the correct locations.