Title: problem with script
Last modified: January 23, 2020

---

# problem with script

 *  [jrubeda](https://wordpress.org/support/users/jrubeda/)
 * (@jrubeda)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/problem-with-script-3/)
 * Good morning everyone and thanks for the help, I do not write many in these forums
   because I always try to look and find the solution but this can with me …. I 
   am trying to put the code so that only the tracking cookies are activated if 
   we give it to accept but I can’t do it … In the template that I have installed
   on my website that is Endfold I have this code,
 *     ```
       if ( function_exists(‘cookie_accepted’) && cookie_accepted() ) {
       <!-- Global site tag (gtag.js) - Google Analytics -->
       <script async src="https://www.googletagmanager.com/gtag/js?id=Google Analytics"></script>
       <script>
         window.dataLayer = window.dataLayer || [];
         function gtag(){dataLayer.push(arguments);}
         gtag('js', new Date());
   
         gtag('config', 'MyID Google Analytics');
       </script>
       }
       ```
   
 * I see that inside the plugin you can put script but as I read in some comments
   you have to put it inside the template, is it correct? What do I have to do to
   make it work?
    -  This topic was modified 6 years, 4 months ago by [jrubeda](https://wordpress.org/support/users/jrubeda/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-with-script-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

The topic ‘problem with script’ is closed to new replies.

 * ![](https://ps.w.org/cookie-notice/assets/icon-256x256.png?rev=3549327)
 * [Compliance by Hu-manity.co](https://wordpress.org/plugins/cookie-notice/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-notice/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-notice/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-notice/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-notice/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-notice/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [jrubeda](https://wordpress.org/support/users/jrubeda/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/problem-with-script-3/)
 * Status: not resolved