How to disable a code in GTM from firing on homepageHow do I use custom image tag?How to avoid double counting GA eCommerce transactions with GTMHow does GTM work and why aren't events firing?How to assign the first user referer (source / medium) to an event with GTM and GA?How to exclude main domain from subdomain tracking in Google Analytics or GTM?How to add AggregateRating in GTM using DOM element Variables?Proxy Sale - Affiliate Fraud on Thank You pageIs it ok to filter sensitive user information from GA hits in GTM (rather than in app)?How to listen to gtm events fire from javascript file in my webpage?How do I implement a setTimeout event to adjust the bounce rate with Google Analytics snippet included in Google Tag Manager?

Does the Bracer of Flying Daggers really let a thief make 4 attacks per round?

Masyu-making game

Why do we need an estimator to be consistent?

What are my hardware upgrade optoins for a late 2009 iMac?

Did Hitler say this quote about homeschooling?

Somebody hacked my clock

Does a hash function have a Upper bound on input length?

Extract the attribute names from a large number of Shapefiles

Should I have one hand on the throttle during engine ignition?

Why are there few or no black super GMs?

Why xargs uses -t to enable verbose mode?

Why would word of Princess Leia's capture generate sympathy for the Rebellion in the Senate?

Are there foods that astronauts are explicitly never allowed to eat?

Why don't humans perceive sound waves as twice the frequency they are?

Project Euler # 25 The 1000 digit Fibonacci index

Simplest instruction set that has an c++/C compiler to write an emulator for?

Could a US citizen born through "birth tourism" become President?

I have found a mistake on someone's code published online: what is the protocol?

Is "repository" pronounced /rɪˈpɒzɪt(ə)ri/ or ri-ˈpä-zə-ˌtȯr-ē or /rəˈpäzəˌtôrē/?

What's the largest an Earth-like planet can be and support Earth's biosphere?

What is the function of "mal" in saying "Das nenn ich mal ein X"?

Are there any satellites in geosynchronous but not geostationary orbits?

When will the last unambiguous evidence of mankind disappear?

Should I have shared a document with a former employee?



How to disable a code in GTM from firing on homepage


How do I use custom image tag?How to avoid double counting GA eCommerce transactions with GTMHow does GTM work and why aren't events firing?How to assign the first user referer (source / medium) to an event with GTM and GA?How to exclude main domain from subdomain tracking in Google Analytics or GTM?How to add AggregateRating in GTM using DOM element Variables?Proxy Sale - Affiliate Fraud on Thank You pageIs it ok to filter sensitive user information from GA hits in GTM (rather than in app)?How to listen to gtm events fire from javascript file in my webpage?How do I implement a setTimeout event to adjust the bounce rate with Google Analytics snippet included in Google Tag Manager?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















How can I disable a code from GTM on homepage? I want that code only on product pages.



Thank you










share|improve this question




























    1















    How can I disable a code from GTM on homepage? I want that code only on product pages.



    Thank you










    share|improve this question
























      1












      1








      1








      How can I disable a code from GTM on homepage? I want that code only on product pages.



      Thank you










      share|improve this question














      How can I disable a code from GTM on homepage? I want that code only on product pages.



      Thank you







      wordpress google-tag-manager






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 11 at 5:45









      Adarsh MAdarsh M

      62 bronze badges




      62 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          7














          Gael's answer is probably the best, but i just wanted to let you know that there's also a possibility of having the GTM container code, but not actually tracking the home page.
          In that case, you just need to create a trigger, that would look like in the image attached.no home page trigger in GTM






          share|improve this answer


















          • 1





            Thanx @Mnea but not sure my answer is the best. Your solution offers the same capabilities with the advantage not to have to edit the theme's files.

            – gael
            Jul 12 at 8:39











          • It actually depends, perhaps OP wanted to speed up the load time on home page for some reason, and by excluding the container this would probably do it. I just had to mention this solution, so that everything is covered.

            – Mnea
            Jul 12 at 15:46


















          3














          The easyest way not to display Google Tag Manager on Homepage is to check with php.



          You can insert GTM in the header.php file of your child-theme like this:



          <?php 
          if (!is_home() && !is_front_page())
          echo 'your GTM code here';

          ?>


          Will display GTM everywhere but on home (blog posts homepage) nor on front page (the static page you may have defined as the home of your wordpress).



          Then if you only want it on product pages there are a bunch of possibilities since there are a lot of product pages types (category page, single product page...).



          But if you want it to display only on a few product pages type you could choose to display it only IF it's the good page type.



          <?php 
          if (is_product())
          echo 'your GTM code here';

          ?>


          You will find woocommerce conditional tags here : https://docs.woocommerce.com/document/conditional-tags/ where you will be able to choose on which condition you want your GTM to display or not.






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "45"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwebmasters.stackexchange.com%2fquestions%2f123938%2fhow-to-disable-a-code-in-gtm-from-firing-on-homepage%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            7














            Gael's answer is probably the best, but i just wanted to let you know that there's also a possibility of having the GTM container code, but not actually tracking the home page.
            In that case, you just need to create a trigger, that would look like in the image attached.no home page trigger in GTM






            share|improve this answer


















            • 1





              Thanx @Mnea but not sure my answer is the best. Your solution offers the same capabilities with the advantage not to have to edit the theme's files.

              – gael
              Jul 12 at 8:39











            • It actually depends, perhaps OP wanted to speed up the load time on home page for some reason, and by excluding the container this would probably do it. I just had to mention this solution, so that everything is covered.

              – Mnea
              Jul 12 at 15:46















            7














            Gael's answer is probably the best, but i just wanted to let you know that there's also a possibility of having the GTM container code, but not actually tracking the home page.
            In that case, you just need to create a trigger, that would look like in the image attached.no home page trigger in GTM






            share|improve this answer


















            • 1





              Thanx @Mnea but not sure my answer is the best. Your solution offers the same capabilities with the advantage not to have to edit the theme's files.

              – gael
              Jul 12 at 8:39











            • It actually depends, perhaps OP wanted to speed up the load time on home page for some reason, and by excluding the container this would probably do it. I just had to mention this solution, so that everything is covered.

              – Mnea
              Jul 12 at 15:46













            7












            7








            7







            Gael's answer is probably the best, but i just wanted to let you know that there's also a possibility of having the GTM container code, but not actually tracking the home page.
            In that case, you just need to create a trigger, that would look like in the image attached.no home page trigger in GTM






            share|improve this answer













            Gael's answer is probably the best, but i just wanted to let you know that there's also a possibility of having the GTM container code, but not actually tracking the home page.
            In that case, you just need to create a trigger, that would look like in the image attached.no home page trigger in GTM







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 11 at 8:45









            MneaMnea

            1267 bronze badges




            1267 bronze badges







            • 1





              Thanx @Mnea but not sure my answer is the best. Your solution offers the same capabilities with the advantage not to have to edit the theme's files.

              – gael
              Jul 12 at 8:39











            • It actually depends, perhaps OP wanted to speed up the load time on home page for some reason, and by excluding the container this would probably do it. I just had to mention this solution, so that everything is covered.

              – Mnea
              Jul 12 at 15:46












            • 1





              Thanx @Mnea but not sure my answer is the best. Your solution offers the same capabilities with the advantage not to have to edit the theme's files.

              – gael
              Jul 12 at 8:39











            • It actually depends, perhaps OP wanted to speed up the load time on home page for some reason, and by excluding the container this would probably do it. I just had to mention this solution, so that everything is covered.

              – Mnea
              Jul 12 at 15:46







            1




            1





            Thanx @Mnea but not sure my answer is the best. Your solution offers the same capabilities with the advantage not to have to edit the theme's files.

            – gael
            Jul 12 at 8:39





            Thanx @Mnea but not sure my answer is the best. Your solution offers the same capabilities with the advantage not to have to edit the theme's files.

            – gael
            Jul 12 at 8:39













            It actually depends, perhaps OP wanted to speed up the load time on home page for some reason, and by excluding the container this would probably do it. I just had to mention this solution, so that everything is covered.

            – Mnea
            Jul 12 at 15:46





            It actually depends, perhaps OP wanted to speed up the load time on home page for some reason, and by excluding the container this would probably do it. I just had to mention this solution, so that everything is covered.

            – Mnea
            Jul 12 at 15:46













            3














            The easyest way not to display Google Tag Manager on Homepage is to check with php.



            You can insert GTM in the header.php file of your child-theme like this:



            <?php 
            if (!is_home() && !is_front_page())
            echo 'your GTM code here';

            ?>


            Will display GTM everywhere but on home (blog posts homepage) nor on front page (the static page you may have defined as the home of your wordpress).



            Then if you only want it on product pages there are a bunch of possibilities since there are a lot of product pages types (category page, single product page...).



            But if you want it to display only on a few product pages type you could choose to display it only IF it's the good page type.



            <?php 
            if (is_product())
            echo 'your GTM code here';

            ?>


            You will find woocommerce conditional tags here : https://docs.woocommerce.com/document/conditional-tags/ where you will be able to choose on which condition you want your GTM to display or not.






            share|improve this answer





























              3














              The easyest way not to display Google Tag Manager on Homepage is to check with php.



              You can insert GTM in the header.php file of your child-theme like this:



              <?php 
              if (!is_home() && !is_front_page())
              echo 'your GTM code here';

              ?>


              Will display GTM everywhere but on home (blog posts homepage) nor on front page (the static page you may have defined as the home of your wordpress).



              Then if you only want it on product pages there are a bunch of possibilities since there are a lot of product pages types (category page, single product page...).



              But if you want it to display only on a few product pages type you could choose to display it only IF it's the good page type.



              <?php 
              if (is_product())
              echo 'your GTM code here';

              ?>


              You will find woocommerce conditional tags here : https://docs.woocommerce.com/document/conditional-tags/ where you will be able to choose on which condition you want your GTM to display or not.






              share|improve this answer



























                3












                3








                3







                The easyest way not to display Google Tag Manager on Homepage is to check with php.



                You can insert GTM in the header.php file of your child-theme like this:



                <?php 
                if (!is_home() && !is_front_page())
                echo 'your GTM code here';

                ?>


                Will display GTM everywhere but on home (blog posts homepage) nor on front page (the static page you may have defined as the home of your wordpress).



                Then if you only want it on product pages there are a bunch of possibilities since there are a lot of product pages types (category page, single product page...).



                But if you want it to display only on a few product pages type you could choose to display it only IF it's the good page type.



                <?php 
                if (is_product())
                echo 'your GTM code here';

                ?>


                You will find woocommerce conditional tags here : https://docs.woocommerce.com/document/conditional-tags/ where you will be able to choose on which condition you want your GTM to display or not.






                share|improve this answer















                The easyest way not to display Google Tag Manager on Homepage is to check with php.



                You can insert GTM in the header.php file of your child-theme like this:



                <?php 
                if (!is_home() && !is_front_page())
                echo 'your GTM code here';

                ?>


                Will display GTM everywhere but on home (blog posts homepage) nor on front page (the static page you may have defined as the home of your wordpress).



                Then if you only want it on product pages there are a bunch of possibilities since there are a lot of product pages types (category page, single product page...).



                But if you want it to display only on a few product pages type you could choose to display it only IF it's the good page type.



                <?php 
                if (is_product())
                echo 'your GTM code here';

                ?>


                You will find woocommerce conditional tags here : https://docs.woocommerce.com/document/conditional-tags/ where you will be able to choose on which condition you want your GTM to display or not.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 11 at 7:51

























                answered Jul 11 at 7:23









                gaelgael

                5861 silver badge9 bronze badges




                5861 silver badge9 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Webmasters Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwebmasters.stackexchange.com%2fquestions%2f123938%2fhow-to-disable-a-code-in-gtm-from-firing-on-homepage%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form