Analytics · Advanced Topics · Track Exit Links

On this page

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 ItemTypeExample ValueDescription
trackExitLinksBooleantrueEnables automatic exit link tracking. Set to true to enable, false to disable.
trackExitIgnoredDomainsArray (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.

Tracking Example

To enable exit link tracking, you can add the following code to your configuration:

Testing & debugging

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.

Collected data

The exit link tracking will fill the fields as described below.

Database fields

This field will contain the URL of the page that carried the exit link including the view_id!. It is split into multiple fields, such as page.url.raw for the raw URL, page.url.host for the host, etc.
Field (BigQuery)Field (Snowflake)ValueDescription
hit_typeHIT_TYPEeventThe hit type for exit link events is always event. This field is used to filter exit link events in queries.
event.categoryEVENT__CATEGORYExitLinkThis field will always contain the value ExitLink for exit link events. It is used to filter exit link events in queries.
event.actionEVENT__ACTIONclickThis field will always contain the value click for exit link events. It is used to filter exit link events in queries.
event.labelEVENT__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.interactionEVENT__INTERACTIONtrueOnesecondbefore 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]

Query examples

Below are examples on how to query the data. It will list all tracked Exit Links of today.

BigQuery

Snowflake