Svelte component for tracking outbound links in analytics.
Currently works with Google Tag Manager (gtag.js). Package assumes that you have already installed gtag.js.
npm i svelte-track-outboundlink -D
The OutboundLink component will be output as an anchor tag. When clicked it will fire a gtag.js event with the following properties:
clickoutboundhref prop valuebeaconImport the component and use it in place of an anchor tag when linking to external pages:
<script>
import OutboundLink from "svelte-track-outboundlink";
</script>
<OutboundLink href="https://www.example.com/" class="example">Example Link</OutboundLink>
The following props are available:
| Name | Type | Default | Example |
|---|---|---|---|
| href | string | javascript:void(0); |
https://www.exmaple.com |
| target | string | undefined |
_blank |
| rel | string | undefined |
noreferrer |