1.0.7 • Published 5 years ago
svelte-track-outboundlink v1.0.7
svelte-track-outboundlink
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.
Install
npm i svelte-track-outboundlink -DThe OutboundLink component will be output as an anchor tag. When clicked it will fire a gtag.js event with the following properties:
- Action:
click - Category:
outbound - Label: the
hrefprop value - Transport type:
beacon
Usage
Import 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 |