Skip to main content

benecaster_email_utm_params

Filter Premium email-editor

Filters the UTM tags added to one kind of link in a broadcast or an episode notification. It runs once per kind of link in each email, after Benecaster has filled in the reader’s merge tags and before click logging puts each link behind its redirect, in the HTML and the text part. Change a value, add your own such as utm_term, or return [] to leave those links untagged. Only fires for a show where the Email Editor is on.

Parameters

Name Type Default Description
$utm_params array — `utm_source` (the email type, `broadcast` or `episode_notification`, for an ordinary link; `listen_link`, `unsubscribe` or `email_settings` for the other kinds), `utm_medium` and `utm_campaign` (the show's, from the **Link tracking** tab), `utm_content` (the episode's slug for an episode notification, empty for a broadcast) and `utm_id` (the same for every reader of one send). Empty values are left off.
$email_type string — `broadcast` or `episode_notification`
$episode_id int|null — The episode for an episode notification; null for a broadcast
$show_id int|null — The show
$link string — `link`, `feed`, `unsubscribe` or `account`. A link is `feed`, `unsubscribe` or `account` when it is exactly that reader's `{{feed_url}}` (or an episode notification's `{{listen_url}}`), `{{unsubscribe_url}}` or `{{account_url}}`; everything else is `link`.

Returns: array

Example

add_filter( 'benecaster_email_utm_params', function ( array $params, string $email_type, ?int $episode_id, ?int $show_id, string $link ): array {
    if ( 'unsubscribe' === $link ) {
        return []; // Leave these links untagged.
    }

    $params['utm_term'] = 'my-term';

    return $params;
}, 10, 5 );

Notes

A tag already on a link is kept. Only http and https links in an href, or Benecaster's label (url) links in the text part, are tagged, so a link whose address must not change, such as a signed third-party one, needs [] from this filter. A listener's own episode link is a link, tagged after its token, which is kept exactly. A preview or test send gets its own utm_id. Walkthrough: Change the UTM tags on a broadcast's or an episode notification's links.

Need this built rather than just documented? See our services →