When Exit Link Tracking is enabled, OneSecondBefore scans your page and replaces all links that begin with http://
or https://
with a special redirect link. This allows us to track when a user clicks on a link that takes them away from your website.
For example, if your page contains a link to https://example.com
or https://example.org
, we’ll count it as an "exit link." When someone clicks one of these links, they’ll first be briefly redirected through our tracking server before being sent to the original destination. This ensures the click is accurately recorded.
This method is much more reliable than using an onClick
event handler, which can sometimes fail due to browser timing issues—especially when navigating to a different domain. By using redirect-based tracking, we avoid those race conditions and ensure every exit click is captured.
Onesecondbefore can automatically track your exit links. In order to do this you have to add the following items to your configuration:
Config Item | Type | Example Value | Description |
---|---|---|---|
trackExitLinks | Boolean | true | Enables automatic exit link tracking. Set to true to enable, false to disable. |
trackExitIgnoredDomains | Array (of domains) | ['example.com', 'example.org'] | Use this array of domains to prevent Onesecondbefore of tracking exit links that are in this list. Usually this contains a list of all your domains that contain Onesecondbefore tracking and you obviously do not want to track as exit links. |
To enable exit link tracking, you can add the following code to your configuration:
osb('config', {
trackExitLinks: true,
trackExitIgnoredDomains: ['example.com', 'example.org']
});
If you switch on debugging with our Debug On Bookmarklet, the JavaScript Console will show which links will be tracked as exit links. Make sure to switch off debugging when you are done testing with Debug Off Bookmarklet.
The exit link tracking will fill the fields as described below.
Field (BigQuery) | Field (Snowflake) | Value | Description |
---|---|---|---|
hit_type | HIT_TYPE | event | The hit type for exit link events is always event . This field is used to filter exit link events in queries. |
event.category | EVENT__CATEGORY | ExitLink | This field will always contain the value ExitLink for exit link events. It is used to filter exit link events in queries. |
event.action | EVENT__ACTION | click | This field will always contain the value click for exit link events. It is used to filter exit link events in queries. |
event.label | EVENT__LABEL | [Full Exit Link URL] | This field will contain the full Exit Link URL, including the protocol (http or https), url parameters and hash. |
event.interaction | EVENT__INTERACTION | true | Onesecondbefore considers clicking on an exit link an interaction that should be part of the sessionization process and therefore sets this flag to true . |
page.url.* | PAGE__URL__* | [URL of page that carried the exit link] |
Below are examples on how to query the data. It will list all tracked Exit Links of today.
select datetime(tstamp, 'Europe/Amsterdam') as dtstamp_local,
user_id,
hit_type,
event,
page.view_id,
page.url.raw
from `osb_analytics.hits_v5`
where date(tstamp, 'Europe/Amsterdam') = current_date('Europe/Amsterdam')
and event.category='ExitLink'
order by tstamp
select CONVERT_TIMEZONE('UTC', 'Europe/Amsterdam', TSTAMP) as DTSTAMP_LOCAL,
USER_ID,
HIT_TYPE,
EVENT__CATEGORY,
EVENT__ACTION,
EVENT__LABEL,
PAGE__VIEW_ID,
PAGE__URL__RAW
from OSB_ANALYTICS.HITS_V5
where CONVERT_TIMEZONE('UTC', 'Europe/Amsterdam', TSTAMP) =
CAST(CONVERT_TIMEZONE('Europe/Amsterdam', CURRENT_TIMESTAMP()) AS DATE)
and EVENT__CATEGORY = 'ExitLink'
order by TSTAMP