Send every Outlinks click to your own analytics as it happens
benecaster_outlinks_click_logged fires each time a visitor follows a tracked /go/ link, right after Outlinks records the click, and only if it was recorded. $episode_id is the episode Outlinks checked belongs to the link’s show, never the raw ?ep value, or null. It also fires for a site-wide link, one that belongs to no show, with $episode_id always null.
Bot clicks are recorded too, so the action fires for them. The fourth argument, $is_bot, says whether Outlinks counted the click as a bot: check it, as below, if you only want people. It never fires for a show where Outlinks is switched off or on a lapsed site, where links redirect without being counted.
Code
<?php
add_action( 'benecaster_outlinks_click_logged', function ( int $click_id, string $slug, ?int $episode_id, bool $is_bot ): void {
if ( $is_bot ) {
return; // Bot clicks are rows too, so the action fires for them.
}
my_analytics_queue( 'outlink_click', [ 'slug' => $slug, 'episode' => $episode_id ] );
}, 10, 4 );
Hooks Used
Need this built rather than just documented? See our services →