svelte-track-outboundlink
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

svelte-track-outboundlink

Commitizen friendly TypeScript

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 -D

The 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 href prop 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

Package Sidebar

Install

npm i svelte-track-outboundlink

Weekly Downloads

3

Version

1.0.7

License

MIT

Unpacked Size

6.4 kB

Total Files

11

Last publish

Collaborators

  • mikachan