Title: Feed Analytics Tracking
Last modified: August 30, 2016

---

# Feed Analytics Tracking

 *  Resolved [linkhousemedia](https://wordpress.org/support/users/linkhousemedia/)
 * (@linkhousemedia)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/feed-analytics-tracking/)
 * Hi Hugh – great plugin! Love it.
 * I’m using it here: [http://flightcast.audio](http://flightcast.audio).
 * I’m using the `ssp_file_download` and `ssp_before_feed` actions to track google
   analytics for both the audio play (download) and the XML feed hit, which is useful
   for iTunes subscriber tracking.
 * My problem is that with PHP analytics tracking (I’m using [https://github.com/dancameron/server-side-google-analytics](https://github.com/dancameron/server-side-google-analytics)),
   you can’t set the visitor’s IP address. So all of my traffic for this looks like
   it’s coming from Chicago which is where my data center is.
 * Do you have plans to add in analytics tracking? Or can you suggest a workaround
   for me to get accurate tracking?
 * Thanks!
    Jay
 * [https://wordpress.org/plugins/seriously-simple-podcasting/](https://wordpress.org/plugins/seriously-simple-podcasting/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [linkhousemedia](https://wordpress.org/support/users/linkhousemedia/)
 * (@linkhousemedia)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/feed-analytics-tracking/#post-6552581)
 * In case anyone is wondering, I’ve solved this. You can easily track your XML 
   feed hits by doing the following:
    - Use a google analytics php api such as [https://github.com/ins0/google-measurement-php-client](https://github.com/ins0/google-measurement-php-client)(
      This is what I’ve used in the example below)
    - Use the plugin’s action hooks to fire off a tracking event
 * `/*-----------------------------------------------------------------------------------*/
   /*
   Add some Analytics tracking to our podcast feed */ /*-----------------------------------------------------------------------------------*/
   function track_podcast_xml(){
 *  require_once(dirname(__FILE__).'/src/Racecore/GATracking/GATracking.php');
 *  $client_ip = $_SERVER["HTTP_CF_CONNECTING_IP"] ? $_SERVER["HTTP_CF_CONNECTING_IP"]:
   $_SERVER['REMOTE_ADDR'];
    $options = array( // use proxy 'proxy' => array( 'ip'
   => $client_ip ) );
 *  $gatracking = new \Racecore\GATracking\GATracking('UA-XXXXXXXX-X', $options);
 *  $event = $gatracking->createTracking('Event');
    $event->setAsNonInteractionHit(
   false); $event->setEventCategory('XML'); $event->setEventAction('FeedHit'); $
   event->setEventLabel('feed/podcast');
 *  $response = $gatracking->sendTracking($event);
 * }
    add_action('ssp_before_feed', 'track_podcast_xml');
 * Side note: I’m using CloudFlare, so you’ll notice the `$_SERVER["HTTP_CF_CONNECTING_IP"]`
   header check.
 * Cheers.
 *  Plugin Contributor [Hugh Lashbrooke](https://wordpress.org/support/users/hlashbrooke/)
 * (@hlashbrooke)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/feed-analytics-tracking/#post-6552652)
 * Thanks for posting this Jay!
 * I’m working on an integrated stats add-on that will reliably track everything,
   but I don’t have an ETA for that just yet as I don’t have a lot of available 
   time to work on it. In the mean time, however, the code you posted here looks
   solid – nice work 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Feed Analytics Tracking’ is closed to new replies.

 * ![](https://ps.w.org/seriously-simple-podcasting/assets/icon-256x256.png?rev=
   970355)
 * [Seriously Simple Podcasting](https://wordpress.org/plugins/seriously-simple-podcasting/)
 * [Support Threads](https://wordpress.org/support/plugin/seriously-simple-podcasting/)
 * [Active Topics](https://wordpress.org/support/plugin/seriously-simple-podcasting/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seriously-simple-podcasting/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seriously-simple-podcasting/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Hugh Lashbrooke](https://wordpress.org/support/users/hlashbrooke/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/feed-analytics-tracking/#post-6552652)
 * Status: resolved