Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter linkhousemedia

    (@linkhousemedia)

    In case anyone is wondering, I’ve solved this. You can easily track your XML feed hits by doing the following:

    /*-----------------------------------------------------------------------------------*/
    /* 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

    (@hlashbrooke)

    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.