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 licence has lapsed, still redirects /go/ links but records nothing, and this hook does not fire.
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, read is_bot from the click’s row by $click_id, as the walkthrough recipe does.
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 or named one from another show |
Examples
Queue each click for your own analytics
add_action( 'benecaster_outlinks_click_logged', function ( int $click_id, string $slug, ?int $episode_id ): void {
my_analytics_queue( 'outlink_click', [ 'slug' => $slug, 'episode' => $episode_id ] );
}, 10, 3 );
Notes
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 →