layers_add_google_analytics

The Layers layers add google analytics function.

Description

layers_add_google_analytics(); 

Usage

  1. if ( !function_exists( 'layers_add_google_analytics' ) ) { 
  2. require_once '/core/helpers/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = layers_add_google_analytics(); 
  7.  

Defined (1)

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

/core/helpers/template.php  
  1. function layers_add_google_analytics() { 
  2. global $wp_customize; 
  3.  
  4. // Bail if in customizer. 
  5. if( isset( $wp_customize ) ) return; 
  6.  
  7. $analytics_id = layers_get_theme_mod( 'header-google-id' ); 
  8.  
  9. if ( '' != $analytics_id ) { ?> 
  10. <script> 
  11. (function(i, s, o, g, r, a, m) {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function() { 
  12. (i[r].q=i[r].q||[]).push(arguments)}, i[r].l=1*new Date();a=s.createElement(o),  
  13. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a, m) 
  14. })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); 
  15.  
  16. ga('create', '<?php echo $analytics_id; ?>', 'auto'); 
  17. ga('send', 'pageview'); 
  18. </script> 
  19. <?php }