benecaster_outlinks_click_logged
Fires when a visitor follows a tracked /go/ link, right after Outlinks has recorded the click, and only if the click was recorded. Use it to send clicks to your own analytics as they happen.
It fires only for a link whose show has Outlinks switched on. A show where Outlinks is switched off, or a site whose license has lapsed, still redirects /go/ links but records nothing, and this hook does not fire.
It also fires for a site-wide link, one that belongs to no show (such as a guest’s book tracked from Guest Manager), while Outlinks is switched on for at least one show. For those clicks $episode_id is always null.
Clicks Outlinks counts as bots (crawlers, link previews, monitoring services, scripts) are recorded too, so the hook fires for them. If you only want people, check $is_bot and return early when it is true.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$click_id |
int |
— | ID of the click just recorded |
$slug |
string |
— | The link's name, the part after `/go/` |
$episode_id |
int|null |
— | The episode the click came from, once Outlinks has checked it belongs to the link's show; null when the link named no episode, named one from another show, or is a site-wide link |
$is_bot |
bool |
— | True when Outlinks counted the click as a bot rather than a person. It is the last argument, so a callback registered for three arguments still runs |
Examples
Queue each person's click for your own analytics
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 recorded too, so the action fires for them.
}
my_analytics_queue( 'outlink_click', [ 'slug' => $slug, 'episode' => $episode_id ] );
}, 10, 4 );
Notes
Register the callback with 4 accepted arguments to receive $is_bot. It runs inside the visitor's redirect, so a slow callback is a slow link for every listener. Queue the work (a cron event or an async request) rather than calling a remote API here. It fires before benecaster_outlinks_before_redirect. Walkthrough: Send every Outlinks click to your own analytics as it happens.
Need this built rather than just documented? See our services →