×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Nicole Patten
Added: Jul 5, 2016 9:02 PM
Views: 11
  1. function add_googleanalytics() {
  2. if (strpos($_SERVER['HTTP_HOST'], PRODUCTION_URL) !== false){ ?>
  3.         <script>
  4.                  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  5.                  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  6.                  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  7.                  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  8.  
  9.                  ga('create', 'UA-##', 'auto');
  10.                  ga('create', 'UA-##', 'auto', 'site2');
  11.                  ga('send', 'pageview');
  12.                  ga('site2.send', 'pageview');
  13.  
  14.         </script>
  15. <?php } }