The Onesecondbefore JavaScript library is only built for tracking to keep it as small as possible. This page explains how to place triggers in combination with the Onesecondbefore tracking library.
<script>
/* Onesecondbefore Analytics Start */
!function(){"use strict";var e,t,n,s,c;e=window,t=document,n="osb",e.$OSB_QUEUENAME=n,
e[n]=e[n]||function(){(e[n].q = e[n].q || []).push(arguments)},s = t.createElement("script"),
c=t.getElementsByTagName("script")[0],s.async=1,
s.src="https://c.onesecondbefore.com/js/osb.min.js",
c.parentNode.insertBefore(s,c)}();
/* Onesecondbefore Analytics Finish */
</script>
Track a page view with Google Tag Manager by doing the following:
<script>
/* Onesecondbefore Analytics Start */
!function(){"use strict";var e,t,n,s,c;e=window,t=document,n="osb",e.$OSB_QUEUENAME=n,
e[n]=e[n]||function(){(e[n].q=e[n].q||[]).push(arguments)},s=t.createElement("script"),
c=t.getElementsByTagName("script")[0],s.async=1,
s.src="https://c.onesecondbefore.com/js/osb.min.js",
c.parentNode.insertBefore(s,c)}();
/* Onesecondbefore Analytics Finish */
</script>
The tag triggers when a visitor clicks on a link leaving the website.
Put the code below in the source code of your page to track exit links. Replace the example domains in the regular expression for your own. Rule of thumb is that all domains with Factbase tracking should not be tracked as an exit link.
<script>
let comp = new RegExp('(www.mydomain.com|www.mydomain2.com)');
let links = document.getElementsByTagName('a');
for (let i = 0, i < links.length; i++) {
if (links.[i].href && !comp.test(links[i].href)) {
links[i].onclick = function() {
osb('send', 'event', {
category: 'Exit links',
action: 'click',
label: this.href
});
}
}
}
</script>
Customize the tracking code as you see fit.
Track a pageview with Google Tag Manager by doing the following:
<script>
osb('send', 'event', {
category: 'Exit links',
action: 'click',
label: {{Click URL}}
});
</script>
Your don't have to put quotes ('
or "
) around {{Click URL}}
. Customize the tracking code as you see fit.
The tag triggers when a visitor clicks on a link to download a file.
Put the code below in the source code of your page to track downloads. .
<script>
var comp = new RegExp('\.(xls|xlsx|doc|docx|pdf|zip|exe|mp3)');
var links = document.getElementsByTagName('a');
for(var i = 0, len = links.length; i < len; i++) {
if (!comp.test(links[i].href)) {
links[i].onclick = function () {
osb('send', 'event', {
category: 'Downloads',
action: 'click',
label: this.href
});
}
}
}
</script>
Customize the tracking code as you see fit.
Track a pageview with Google Tag Manager by doing the following:
<script>
osb('send', 'event', {
category: 'Downloads',
action: 'click',
label: {{Click URL}}
});
</script>
You don't have to put quotes ('
or "
) around {{Click URL}}
. Customize the tracking code as you see fit.