{"id":1201,"date":"2010-07-11T13:48:54","date_gmt":"2010-07-11T08:18:54","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1201"},"modified":"2016-12-19T15:06:26","modified_gmt":"2016-12-19T09:36:26","slug":"suppress-tracking-of-various-scripts-on-test-and-development-environment","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/suppress-tracking-of-various-scripts-on-test-and-development-environment\/","title":{"rendered":"Suppress Tracking of various scripts on test and development environment"},"content":{"rendered":"<p>In my recent project, every time the page loads, it loads with lots of scripts making calls to and getting content from googleapis, fb, clixpy, cdn etc. to provide the functionality, due to which the page loads very slowly and this led to the wastage of time to test a certain functionality.<\/p>\n<p>To overcome this problem in <a href=\"http:\/\/www.tothenew.com\/grails-application-development\">test and development environment<\/a> and at the same time to run those script in the production environment, I added the &#8220;suppressTracker&#8221; tag that enable or disable the script on the basis of environment on which it is executing or on the basis of session set for tracker.<\/p>\n<p>Step 1 : Create the suppressTracker tag in your tagLib,<\/p>\n<pre lang=\"groovy\">import grails.util.Environment;\r\n\r\ndef suppressTracking = {attrs, body -&gt;\r\n        if (Environment.currentEnvironment==Environment.PRODUCTION &amp;&amp; !session.suppressTracking){\r\n            out&lt;&lt; body()\r\n        }\r\n}\r\n<\/pre>\n<p>Step 2 : Add suppressTracker tag on the script which you want to suppress for test and development environment,<\/p>\n<pre lang=\"groovy\"><script type=\"text\/javascript\">\/\/ <![CDATA[\r\n       Your Script Code ..........\r\n  \r\n\/\/ ]]><\/script><\/pre>\n<p>Hope this code will help \ud83d\ude42<\/p>\n<p>~Regards,<br \/>\nTarun<br \/>\nIntelligrape Software<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my recent project, every time the page loads, it loads with lots of scripts making calls to and getting content from googleapis, fb, clixpy, cdn etc. to provide the functionality, due to which the page loads very slowly and this led to the wastage of time to test a certain functionality. To overcome this [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1201"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1201"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1201\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}