# Custom Event Tracking

> Learn how to track custom events like button clicks, form views, and video plays using the AnyTrack Event Snippet. Covers the trigger command, standard and custom event names, event attributes for enriching conversion data, automatic event mapping to ad platforms, and validation using the Tracking Tag Helper extension.

**Custom events** are user-defined tracking events specific to a property's goals — beyond AnyTrack's [standard events](/docs/standard-events) like `Purchase`, `Lead`, or `ViewContent`. They let you track unique actions such as button clicks, video plays, scroll depth, or quiz completions, then send that enriched data to all connected ad platforms via Conversion API for attribution, audience building, and campaign optimization.

Custom events give you complete control over what gets tracked and when, so ad platforms receive the exact signals they need to optimize performance.

> ❗ **Important**
>
> Custom event tracking requires HTML and JavaScript knowledge. If you are not comfortable with code, share this guide with your developer.

<Prerequisites
  title="Before you begin"
  items={[
    { label: "The Tracking Tag is installed on your website", done: true },
    { label: "You have HTML and JavaScript knowledge", done: true },
    { label: "You have an active AnyTrack property", done: true },
  ]}
/>

## The Trigger Command

Every AnyTrack event snippet has three parts:

1. **The Trigger**: The command that generates the event.
2. **The Event Name**: Standard event (like `ViewContent`, `Lead`, `Purchase`) or custom event name.
3. **The Event Attributes**: Customer data (email, phone), product details (SKU, value, currency), and other context that enriches your tracking. See the complete list of [Event Attributes](/docs/event-attributes).

```javascript AnyTrack Event Snippet
<script>
  var click_id = AnyTrack('trigger', 'ViewContent', {
      brand: 'Nike',
      label: 'shoes',
      value: 199.00,
      currency: 'USD'
  });
</script>
```

> 📘 **Note**
>
> The snippet returns a `click_id` value (like `MAbFl0fhrE5EfBu6fX0FnL02LfS`) that you can push to your CRM to connect offline conversions back to the original ad click.

> ❗ **Important**
>
> Standard events like `Purchase`, `Lead`, or `ViewContent` are automatically mapped to each ad platform's equivalent event. When AnyTrack tracks a `Purchase` event, Facebook receives it as a Facebook `Purchase` event, Google receives it as a Google `purchase` conversion, and so on.

## Trigger Custom Events

Use custom event names when standard events don't match your tracking needs:

```javascript
<script>
var click_id = AnyTrack('trigger', 'Optin');
</script>
```

## Conversion Event Mapping

Standard events are automatically forwarded to ad platforms. Custom events require manual mapping — follow our guide to [map custom events to your ad platforms](/docs/facebook-custom-conversions#why-custom-conversions) so platforms can use them for optimization.

## Event Attributes

Send customer data and product details with every event to boost Event Match Quality and give ad platforms the rich signals they need to optimize effectively. Higher Event Match Quality means better attribution, smarter targeting, and improved ROAS.

```javascript
<script>
var click_id = AnyTrack('trigger', 'Optin', {
  formId: 'form82323',
	brand: 'newsletter',
	email: 'jondoe@email.com'
});
</script>
```

Attributes like `email`, `phone`, `value`, `currency`, and `transaction_id` flow to AnyTrack and all connected ad platforms, giving you consistent, enriched data everywhere.

See all supported [Event Attributes](/docs/event-attributes).

## Validate Your Custom Events

Catch tracking issues before they cost you money. Validation takes 30 seconds using the Tracking Tag Helper Chrome Extension.

**Step 1: Verify the snippet is found**

Navigate to the page where you added the snippet, open the [Tracking Tag Helper Chrome Extension](/docs/anytrack-chrome-extension), and click "Snippets found." Your custom event snippet should appear in the list.

<Image align="center" alt="The Tracking Tag Helper Chrome Extension shows all the event snippets found on the page." border={true} caption="The Tracking Tag Helper extension shows all event snippets found." src={readmeAsset1} width="600" />

**Step 2: Confirm the event fired**

On the same page, check the Tracking Tag Helper again. A green checkmark with timestamp means the event triggered successfully. Click the ClientId link to view details.

<Image align="center" alt="Click the ClientId link to see the event in the Conversion Report. " border={true} caption="if successful, the event and its identifiers will be visible." src={readmeAsset2} />

**Step 3: Review in Conversion Report**

The ClientId link opens the Conversion Report showing your triggered event. Verify the event data looks correct, then [map the event](/docs/facebook-custom-conversions#why-custom-conversions) to your connected ad platforms so they can receive and use the conversion signals.

<Image align="center" alt="The Conversion Report will show the events triggered by the snippet code." border={true} caption="The Conversion Report will show the events triggered by the snippet code." src={readmeAsset3} />

## Troubleshooting: Event Not Triggering

If the Tracking Tag Helper shows both the Tag and the event snippet are installed but the event is not firing, the snippet is likely executing before the Tag finishes loading. This commonly happens when the Tag loads through a tag manager.

**Solution 1:** Configure your tag manager to fire the event snippet after the Tracking Tag loads completely.

**Solution 2:** Install the Tracking Tag directly in your page `<head>` section instead of through a tag manager — this guarantees it loads before your event snippets.

**Solution 3:** Add a delay to the snippet, giving the Tag time to load:

```javascript
<script>
  var delay = 2000; // Delay in milliseconds (2 seconds)
  function triggerAnyTrack() {
    var click_id = AnyTrack('trigger', 'SignUp');
  }
  setTimeout(triggerAnyTrack, delay);
</script>
```

***

<FaqAccordion
  title="FAQ & Troubleshooting"
  items={[
    {
      question: "What is the difference between standard and custom events?",
      answer: "Standard events like Purchase, Lead, and ViewContent are automatically mapped to each ad platform's equivalent event. Custom events use your own names and require manual mapping in your ad platform. See the custom event mapping guide for setup instructions."
    },
    {
      question: "Do I need to add event snippets to every page?",
      answer: "No. Add event snippets only to pages where the specific action occurs. The Tracking Tag handles automatic tracking (page views, outbound clicks, form submissions) across all pages."
    },
    {
      question: "How do I validate that my custom event is working?",
      answer: "Use the Tracking Tag Helper Chrome extension to verify the snippet is found and the event fires. Then check the Conversion Report in your dashboard to confirm the event data."
    }
  ]}
/>

## Related

- [Custom Event Mapping](/docs/facebook-custom-conversions)
- [Tracking Tag Helper Chrome Extension](/docs/anytrack-chrome-extension)
- [Event Attributes](/docs/event-attributes)
