DN_Google_Analytics

The Google Analytics by DN DN Google Analytics class.

Defined (1)

The class is defined in the following location(s).

/class.dn_google_analytics.php  
  1. class DN_Google_Analytics { 
  2.  
  3. function __construct() { 
  4. add_action( 'wp_head', array( $this, 'add_google_analytics' ), 1 ); 
  5.  
  6. public function add_google_analytics() { 
  7. $options = get_option( 'dn_google_analytics_settings_option' ); 
  8.  
  9. if ($options['tracking_id'] != null) { 
  10. $tracking_id = $options['tracking_id']; 
  11. } else { 
  12. return; 
  13.  
  14. if ($options['anonymize_ip'] == 1) { 
  15. $anonymize_ip = $options['anonymize_ip']; 
  16. }  
  17.  
  18. //  
  19.  
  20. printf(" 
  21. <!-- Google Analytics --> 
  22. <script async src='//www.google-analytics.com/analytics.js'></script> 
  23. <script> 
  24. window.ga=window.ga||function() {(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; 
  25. ga('create', '%s', 'auto'); 
  26. %s 
  27. ga('send', 'pageview'); 
  28. </script> 
  29. <!-- End Google Analytics --> 
  30. ", $tracking_id,  
  31. isset( $options['anonymize_ip'] ) ? "ga('set', 'anonymizeIp', true);" : ""); 
  32.  
  33.