Yoast_GA_Frontend

The basic frontend class for the GA plugin, extendable for the children.

Defined (1)

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

/frontend/class-frontend.php  
  1. class Yoast_GA_Frontend { 
  2.  
  3. /** @var array $options */ 
  4. protected $options; 
  5.  
  6. /** 
  7. * Class constructor 
  8. */ 
  9. public function __construct() { 
  10.  
  11. $this->options = Yoast_GA_Options::instance()->options; 
  12.  
  13. if ( isset( $this->options['tag_links_in_rss'] ) && $this->options['tag_links_in_rss'] == 1 ) { 
  14. add_filter( 'the_permalink_rss', array( $this, 'rsslinktagger' ), 99 ); 
  15.  
  16. // Check if the customer is running Universal or not (Enable in GA Settings -> Universal) 
  17. if ( isset( $this->options['enable_universal'] ) && $this->options['enable_universal'] == 1 ) { 
  18. new Yoast_GA_Universal; 
  19. else { 
  20. new Yoast_GA_JS; 
  21.  
  22.  
  23. /** 
  24. * Add the UTM source parameters in the RSS feeds to track traffic 
  25. * @param string $guid 
  26. * @return string 
  27. */ 
  28. public function rsslinktagger( $guid ) { 
  29. global $post; 
  30. if ( is_feed() ) { 
  31. if ( $this->options['allow_anchor'] ) { 
  32. $delimiter = '#'; 
  33. else { 
  34. $delimiter = '?'; 
  35. if ( strpos( $guid, $delimiter ) > 0 ) { 
  36. $delimiter = '&'; 
  37.  
  38. return $guid . $delimiter . 'utm_source=rss&utm_medium=rss&utm_campaign=' . urlencode( $post->post_name ); 
  39.  
  40. return $guid; 
  41.