Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter d00mer

    (@d00mer)

    i tried like here https://korben.info/respecter-loi-cookies-site.html

    <script>
    if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) {
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-69175630-1', 'auto');
      ga('send', 'pageview');
    }
    </script>

    but doesnt working.
    what is wrong ?

    Same question for me, but the developer won’t answer. Unfortunately…

    Plugin Author dFactory

    (@dfactory)

    @d00mer you have mixed javascript and php code.

    cn_cookies_accepted() is a php function, while it resides in a script tag.

    The correct syntax would be sth like (but it depends where the function is places etc.):

    <?php
    if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) { ?>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-69175630-1', 'auto');
      ga('send', 'pageview');
    </script>
    <?php } ?>

    @neiltomlow this is itended for developers. If you have difficulties making use of it just use the code block in the plugin settings and paste your javascript code there.

    Regards,
    Bartosz / dfactory team

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How does cookie function work?’ is closed to new replies.