Campaign Tags on Feed Item Links
Adds utm_source, utm_medium and utm_campaign parameters to the links in your RSS feed, so visits from feed readers and RSS emails show up clearly in your analytics.
Opens WPIDE on
Code
// Campaign parameters added to feed links.
$wpide_feed_utm = array(
'utm_source' => 'rss',
'utm_medium' => 'feed',
'utm_campaign' => 'rss-feed',
);
add_filter( 'the_permalink_rss', function ( $link ) use ( $wpide_feed_utm ) {
return add_query_arg( array_map( 'rawurlencode', $wpide_feed_utm ), $link );
} );
Notes
Change the parameter values to match your analytics naming.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.