Skip to content
Permalink
Browse files

Fixes for feed trackung in WordPress

  • Loading branch information
Peter Adams
Peter Adams committed Jan 15, 2020
1 parent dbf270b commit 75ca1ed51dd4dfd091a07501da38ea568a418ae5
Showing with 59 additions and 32 deletions.
  1. +0 −7 modules/base/handlers/feedRequestHandlers.php
  2. +7 −0 modules/base/module.php
  3. +4 −4 owa_wp.php
  4. +48 −21 wp_plugin.php
@@ -49,13 +49,6 @@ function notify( $event ) {

if ( ! $f->wasPersisted() ) {

// rekey Feed subscription id tracking code
// @todo check the wordpress plugin to see if this is even needed
if ( ! $event->get( 'feed_subscription_id' ) ) {

$event->set( 'feed_subscription_id', $event->get( owa_coreAPI::getSetting( 'base', 'feed_subscription_param' ) ) );
}

// needed??
$event->set('feed_reader_guid', $event->setEnvGUID() );
// set feedreader flag to true, browser flag to false
@@ -250,6 +250,13 @@ public function setupTrackingProperties() {

),

'feed_subscription_id' => array(
'required' => false,
'callbacks' => array( ),
'default_value' => null,
'alternative_key' => 'sid'
),

'attribs' => array(
'required' => false,
'data_type' => 'json',
@@ -77,15 +77,15 @@ function add_link_tracking($link) {
* @var string the feed link
* @return string link string with special tracking id
*/
function add_feed_tracking($binfo) {
function add_feed_tracking( $binfo ) {

if ($this->config['track_feed_links'] == true):
if ($this->config['track_feed_links'] == true) {
$guid = crc32(getmypid().microtime());

return $binfo."&".$this->config['ns'].$this->config['feed_subscription_param']."=".$guid;
else:
} else {
return;
endif;
}
}
}

@@ -28,7 +28,7 @@
require_once('owa_env.php');

// Filter and Action hook assignments
add_action('template_redirect', 'owa_main');

add_action('wp_head', 'owa_insertPageTags',100);
add_filter('the_permalink_rss', 'owa_post_link');
add_action('init', 'owa_handleSpecialActionRequest');
@@ -242,26 +242,6 @@ function owa_insertPageTags() {
$owa->placeHelperPageTags(true, $options);
}

/**
* This is the main logging controller that is called on each request.
*
*/
function owa_main() {

//global $user_level;

$owa = owa_getInstance();
owa_coreAPI::debug('wp main request method');

//Check to see if this is a Feed Reeder
if( $owa->getSetting('base', 'log_feedreaders') && is_feed() ) {
$event = $owa->makeEvent();
$event->setEventType('base.feed_request');
$event->set('feed_format', $_GET['feed']);
// Process the request by calling owa
return $owa->trackEvent($event);
}
}

/**
* Wordpress filter function adds a GUID to the feed URL.
@@ -465,11 +445,28 @@ function defineActionHooks() {
add_action( 'transition_post_status', array( $this, 'trackPostAction') , 10, 3);
// New Blog (WPMU)
add_action( 'wpmu_new_blog', array( $this, 'trackNewBlogAction') , 10, 5);


// track feeds

add_action('init', array( $this, 'addFeedTrackingQueryParams'));
add_action( 'template_redirect', array( $this, 'trackFeedRequest'), 1 );



}

// These hooks do NOT rely on OWA being accessable via PHP

}

// Add query vars to WordPress
function addFeedTrackingQueryParams() {

global $wp;

// feed tracking param
$wp->add_query_var('owa_sid');

}

@@ -784,6 +781,31 @@ function trackCommentEditAction( $new_status, $old_status, $comment ) {
}
}

// Tracks feed requests
function trackFeedRequest() {

if ( is_feed() ) {


$owa = $this->getOwaInstance();

if( $owa->getSetting( 'base', 'log_feedreaders') ) {

owa_coreAPI::debug('Tracking WordPress feed request');

$event = $owa->makeEvent();
// set event type
$event->setEventType( 'base.feed_request' );
// determine and set the type of feed
$event->set( 'feed_format', get_query_var( 'feed' ) );
$event->set( 'feed_subscription_id', get_query_var( 'owa_sid' ) );
//$event->set( 'feed_subscription_id', $_GET['owa_sid'] );
// track
$owa->trackEvent( $event );
}
}
}

// adds the JavaScript Tracker cmds and script tag to the page.
function addTrackerToPage() {

@@ -793,6 +815,11 @@ function addTrackerToPage() {
//Output the script

}

function generateUniqueNumericId() {

return crc32(getmypid().microtime());
}
}

?>

0 comments on commit 75ca1ed

Please sign in to comment.
You can’t perform that action at this time.