Hi Marco, you can disable the default tracking pixel in plugin setting page, then you can use the newsletter content filter to add your tracking pixel.
This is a quick sample, just a starting point:
function custom_alo_em_tracking_pxl ( $content, $newsletter, $recipient ) {
// If $recipient is not defined, don't track (e.g. it's a test email)
if ( isset( $recipient->ID, $recipient->unikey ) ) {
// This is the default tracking by EasyMail: replace with yours
$track_vars = $recipient->ID . '|' . $recipient->unikey;
$track_vars = urlencode( base64_encode( $track_vars ) );
$tracking_view = '<img src="'. ALO_EM_PLUGIN_URL .'/tr.php?v='. $track_vars .'" width="1" height="1" border="0" alt="" >';
// Insert tracking img before </body> if tag exists, otherwise at the end
if ( strpos( $content, "</body") !== false ) {
$content = str_replace( "</body", $tracking_view ."\n</body" , $content );
} else {
$content .= $tracking_view;
}
}
return $content;
}
add_filter ( 'alo_easymail_newsletter_content', 'custom_alo_em_tracking_pxl', 20, 3 );
I hope it helps.
-
This reply was modified 5 years, 7 months ago by eventualo.
Thank you for your help, Alo!
Tracking pixel is added all right, Spamassassin treats it like a normal image.
Unfortunately, it doesn’t track.
I copied tr.php to website root folder, changed “no” to “yes” in the line below,
if ( get_option(‘alo_em_use_tracking_pixel’) == ‘yes’ ) exit;
but it doesn’t track.
I’ll have to check something else…
Thanks.
Marco.
Tracking works all right.
wp_load pointed to non-existent directory ( was ../../../wp-load.php).
define(‘WP_USE_THEMES’, false);
include(‘wp-load.php’);
Thanks again.
Marco