# Interest shown

Learn how to track topics a user may be interested in.

This event tracks topics that a user may be interested in based on their interactions with your application or website. For example, users spending time on a specific page, clicking on a specific category, or searching for a specific topic.

> **When should I track this event?**
>
> Track this event when a user views content or performs an action that indicates their interest in something.

## Implementation

Here is an example of how to track this event:

**JavaScript**

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

croct.track('interestShown', {
  interests: [
    'ab testing', 
    'analytics', 
    'data science'
  ]
});
```

**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('interestShown', {
        interests: [
          'ab testing', 
          'analytics', 
          'data science'
        ]
      });
  </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('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  });

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('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  });

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('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  });

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('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  });

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

**Vue — JavaScript**

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

const croct = useCroct()

const track = () => croct.track('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  })
</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('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  })
</script>

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

**Nuxt — JavaScript**

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

const track = () => croct.track('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  })
</script>

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

**Nuxt — TypeScript**

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

const track = (): void => croct.track('interestShown', {
    interests: [
      'ab testing', 
      'analytics', 
      'data science'
    ]
  })
</script>

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

## Input properties

These are the supported properties:

- `interests`: `Array<string>`

  The list of topics the user may be interested in. For example, "ab testing", "analytics", "data science", etc.

  The value must be an array of up to 10 strings between 1 and 50 characters long.

## Processed properties

This event has no processed properties.

## Payload examples

Below are some payload examples for this event:

**Basic payload**

```json
{
  "interests": ["ab testing", "analytics", "data science"]
}
```

**Processed payload**

```json
{
  "type": "interestShown",
  "interests": ["ab testing", "analytics", "data science"]
}
```

## Explore

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