Track Outbound Links in Prodio
When a user clicks on a link to an external site, this event is normally not captured because the user is leaving the site where Prodio runs. However, you can use events to track this behavior.
Using Data Attributes
To track outbound links, add data attributes to the anchor tag containing the external link. When the tag is clicked, the event will be triggered. For example:
<a href="https://www.external-website.com"
data-Prodio-event="outbound-link-click"
data-Prodio-event-url="https://www.external-website.com"
>
External link
</a>
This sends an event named outbound-link-click with the value of url
set to the external URL.
Automating Event Attributes
If you don’t want to manually update all your anchor tags, use the following script to automatically add the event attributes to all outbound tags. Place this script at the bottom of your HTML body:
<script type="text/javascript">
(() => {
const name = 'outbound-link-click';
document.querySelectorAll('a').forEach(a => {
if (a.host !== window.location.host && !a.getAttribute('data-Prodio-event')) {
a.setAttribute('data-Prodio-event', name);
a.setAttribute('data-Prodio-event-url', a.href);
}
});
})();
</script>
Verifying Outbound Link Tracking
After implementing the above, verify the tracking by clicking on an outbound link and checking the Events section in your Prodio dashboard.
For further guidance, visit our Help Center or reach out to support.