# Link opened

Learn how to track when a user opens a link.

This event tracks when a user opens a link that may be relevant for analysis or personalization purposes.

> **Automatically tracked**
>
> The SDK automatically tracks this event when a user opens a link.

## Implementation

Here is an example of how to track this event:

**JavaScript**

```javascript
import croct from '@croct/plug';

croct.track('linkOpened', {
  link: 'https://example.com/download/whitepaper.pdf'
});
```

**HTML**

```html
<!DOCTYPE html>
<html>
<head>
  <title>My awesome application</title>
  <script src="https://cdn.croct.io/js/v1/lib/plug.js"></script>
  <script>croct.plug({appId: 'APPLICATION_ID'});</script>
</head>
<body>
  <script>
    const track = () => croct.track('linkOpened', {
        link: 'https://example.com/download/whitepaper.pdf'
      });
  </script>
  <button onclick="track()">Trigger</button>
</body>
</html>
```

**React — JavaScript**

```jsx
import {useCroct} from '@croct/plug-react';

export function Example() {
const croct = useCroct();

const track = () => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  });

return (<button onClick={track}>Trigger</button>);
}
```

**React — TypeScript**

```typescript
import {useCroct} from '@croct/plug-react';
import type {ReactElement} from 'react';

export function Example(): ReactElement {
const croct = useCroct();

const track = () => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  });

return (<button onClick={track}>Trigger</button>);
}
```

**Next — JavaScript**

```jsx
import {useCroct} from '@croct/plug-next';

export function Example() {
const croct = useCroct();

const track = () => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  });

return (<button onClick={track}>Trigger</button>);
}
```

**Next — TypeScript**

```tsx
import {useCroct} from '@croct/plug-next';
import type {ReactElement} from 'react';

export function Example(): ReactElement {
const croct = useCroct();

const track = () => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  });

return (<button onClick={track}>Trigger</button>);
}
```

**Vue — JavaScript**

```vue
<script setup>
import {useCroct} from '@croct/plug-vue'

const croct = useCroct()

const track = () => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  })
</script>

<template>
  <button @click="track">Trigger</button>
</template>
```

**Vue — TypeScript**

```vue
<script setup lang="ts">
import {useCroct} from '@croct/plug-vue'

const croct = useCroct()

const track = (): void => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  })
</script>

<template>
  <button @click="track">Trigger</button>
</template>
```

**Nuxt — JavaScript**

```vue
<script setup>
const croct = useCroct()

const track = () => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  })
</script>

<template>
<button @click="track">Trigger</button>
</template>
```

**Nuxt — TypeScript**

```vue
<script setup lang="ts">
const croct = useCroct()

const track = (): void => croct.track('linkOpened', {
    link: 'https://example.com/download/whitepaper.pdf'
  })
</script>

<template>
<button @click="track">Trigger</button>
</template>
```

## Input properties

These are the supported properties:

- `link`: `string`

  The URL of the link the user opened.

## Processed properties

This event has no processed properties.

## Payload examples

Below are some payload examples for this event:

**Basic payload**

```json
{
   "link": "https://example.com/download/whitepaper.pdf"
}
```

**Processed payload**

```json
{
  "type": "linkOpened",
  "link": "https://example.com/download/whitepaper.pdf"
}
```

## Explore

- [Analytics](/reference/analytics): Learn how to analyze your dashboards.
- [Event-based audiences](/reference/cql/expressions/events/event-types/link-opened): Learn how to create audiences based on this event.
