# 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.

- Type: PHP
- Runs: Run everywhere
- Category: [RSS Feeds](https://wpide.com/library/category/rss/)
- Tags: rss, utm, analytics
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/utm-tags-on-feed-links/

## Code

```php
// 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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Campaign Tags on Feed Item Links" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
