Custom Event Tracking

Learn how to trigger standard and custom events on your website.

Sometimes you need more control over which events get triggered on your website and when. AnyTrack TAG supports trigger standard and custom events programmatically as needed.


Coding skills required

Trigger custom events requires HTML and JavaScript skills. Please contact a web developer if you don’t feel comfortable doing that yourself.



The event snippets below only work if the AnyTrack tag is set on the head of your website.

The Trigger Command:

The AnyTrack Event Snippet is composed of three arguments:

  1. The Trigger: The command that generates the event.
  2. The Event Name: Standard or Custom event name.
  3. The Event Attributes: Contextual data giving more information about the actual event.
  var click_id = AnyTrack('trigger', 'ViewContent');


Good to know

The return argument is the event click_idvalue such as MAbFl0fhrE5EfBu6fX0FnL02LfS which can be pushed to your CRM in order to track offline conversions.


Event Mapping

AnyTrack Standard events are automatically mapped to ad platforms standard events. For example, when AnyTrack tracks a Purchase event, it is automatically sent to Facebook Purchase event.

Trigger Custom Events

If you need more flexibility on the naming convention for your events, you can use custom event names using the following snippet:

var click_id = AnyTrack('trigger', 'Optin');

Conversion event mapping

If the snippet is firing a standard event, such as Purchase, it will be automatically forwarded to the ad pixel as a Purchase. If you are firing a custom event, make sure you map the event to your ad network.

Event attributes

It is recommended to send additional attributes with standard or custom events in order to enrich your pixels with granular data points.

var click_id = AnyTrack('trigger', 'Optin', {
  formId: 'form82323',
	brand_name: 'newsletter',
	email: '[email protected]'

For example, you can send event attributes such as brand_name or transaction_id which will then be available in AnyTrack as well as in your ad platforms.

➡️ Check out the complete list of supported Event Attributes.

Validate Your Custom Events

First, validate that the custom event snippet is found and recognized. Navigate to the page where the snippet is inserted, click the AnyTrack Pixel Helper Chrome Extension, and click on Snippets found. If found, it will be listed.

The AnyTrack Pixel Helper Chrome Extension shows all the event snippets found on the page.

The AnyTrack Pixel Helper extension shows all event snippets found.

Now, validate that the event snippet is triggered. On the page where the snippet is inserted, click the AnyTrack Pixel Helper Chrome Extension. If the event was correctly triggered, a green checkmark and the date and time will be visible. Click on the ClientId.

Click the ClientId link to see the event in the Conversions Report.

if successful, the event and its identifiers will be visible.

This will take you to the Conversions Report, where you will find the event that was triggered by the snippet. Make sure that you map the event to your connected ad networks and analytics.

The Conversions Report will show the events triggered by the snippet code.

The Conversions Report will show the events triggered by the snippet code.


Why is the custom event not triggering, if the AnyTrack Pixel Helper shows that both the AnyTrack Tag and the event code snippet are found and installed?

One possible reason is that the snippet is firing before the AnyTrack Tag loads. This can happen if you are deploying the AnyTrack Tag with a tag manager. There are different solutions to address this issue:

  1. Use the Tag Manager to Control Loading Order: Configure the tag manager to load the snippet after the AnyTrack Tag.

  2. Install the AnyTrack Tag Directly on Your Page: Ensure that the AnyTrack Tag runs before the code snippet by installing it directly on your page.

  3. Introduce a Delay in the Snippet Execution: Use a code that introduces a delay so that the snippet runs after the tracking tag. For example, you can delay the snippet with this code:

      // Delay in milliseconds (e.g., 2000ms = 2 seconds)
      var delay = 2000;
      // Function to trigger AnyTrack after the specified delay
      function triggerAnyTrack() {
        var click_id = AnyTrack('trigger', 'SignUp');
      // Set the timeout to delay the execution
      setTimeout(triggerAnyTrack, delay);