How to install Google Tag Manager via Code Snippet plugin?

This article will show how to install GTM without editing WordPress theme
Share on facebook
Share on twitter
Share on linkedin

Google Tag Manager, aka GTM, is a great free tool by Google to deploy code snippets to websites and apps.

This includes tracking of your website visitors, conversions, and social media pixels. Not just those, you can add many more types of codes.

Before GTM, all tracking codes needed to be hard coded into your website. Now, you can add those codes in matter of minutes without touching your website.

This article shows how to install Google Tag Manager via Code Snippet plugin only.

First get the installation code from your GTM.

  1. Log in to your GTM account.
  2. Choose the correct website (if you have two or more).
  3. Go to Admin
  4. Then click on Install Google Tag Manager
  5. You will need the two code snippets.

How to install Google Tag Manager using Code Snipped Plugin?

  1. Go to your WordPress dashboard and click on Snippets
  2. Click Add New
  3. Enter a title for the snippet "Google Tag Manager"
  4. Replace the GTM-ABCDEF2 with your GTM code.

    add_action( 'wp_head', function () { ?>
    <!– 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-ABCDEF2');</script><!– End Google Tag Manager –>
    <?php }, 1 );
    add_action( 'wp_footer', function () { ?><!– Google Tag Manager (noscript) –><noscript><iframe src="https://www.googletagmanager.com/ns.html?id= GTM-ABCDEF2"height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><!– End Google Tag Manager (noscript) –><?php }, 1 );

  5. Make sure 'Run snippet everywhere' is selected
  6. Give a description for future reference.
  7. Click Save Changes and Activate

How to check the if GTM is installed correctly?

Simply go to www.gachecker.com enter you domain > Check Your Site > Click on Tag Manager.

Share on facebook
Facebook
Share on linkedin
LinkedIn
Share on twitter
Twitter

Subscribe to updates

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top