Made in Builder.io

Announcing Visual Copilot - Figma to live in half the time

Builder.io logo
Talk to Us
Platform
Developers
Talk to Us

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

You can track custom events to evaluate your content's performance. For example, you can:

  • measure A/B test performance by custom events, such as add-to-cart rates or average order value
  • break down impressions and conversions by product views or orders
  • build completely custom dashboards associated with Builder content and sessions

You can track a custom event using JavaScript or with the Visual Editor's JS editor or within your own codebase. Custom events can have any name.

In Builder content or from the the custom JavaScript panel, track an event within an action binding:

builder.track('yourEventName');

Alternatively, you can track a custom event using JavaScript within your own codebase:

// Or, track an event within your project's code
import { builder } from '@builder.io/sdk';
builder.track('yourEventName');

If you're using web components, such as Shopify hosted, you can access the global Builder instance from any script tag or function. Note that in this case, you might need to wrap the call in a setTimeout() to ensure BuilderWC is loaded:

BuilderWC.builder.track('yourEventName');

To import the latest SDK, specify the framework as follows:

import { track } from '@builder.io/sdk-...'

// Next.js, App Router
import { BuilderContent } from "@builder.io/sdk";

// Qwik
import { getContent } from "@builder.io/sdk-qwik";
import {
  getContent,
  RenderContent,
  getBuilderSearchParams,
  type RegisteredComponent,
} from "@builder.io/sdk-qwik";

//  React, Remix, Hydrogen, Gatsby
import { BuilderComponent, builder, useIsPreviewing } from "@builder.io/react";
import { BuilderComponent, builder } from "@builder.io/react";
import { BuilderComponent } from '@builder.io/react';


// Vue
import { getContent, RenderContent, isPreviewing } from '@builder.io/sdk-vue/vue2';
import { getContent, RenderContent, isPreviewing } from '@builder.io/sdk-vue/vue3';

// Nuxt
import { RenderContent, getContent, isPreviewing } from '@builder.io/sdk-vue'


//  Svelte
import { RenderContent } from '@builder.io/sdk-svelte';

//  Angular
import { BuilderModule } from '@builder.io/angular';



To display metrics for your custom events on the overview dashboard, take the following steps from the content entry where you use your custom event:

  1. Navigate to the Insights tab.
  2. Click on the three dots in the top right corner and choose Customize Metrics.
  3. Select Manage Custom Events.
  4. Add a new event to start tracking your custom event on the dashboard.

5. Enter the Event Name, matching the string supplied to builder.track().

6. Add a Display Name to label your custom metric on the dashboard.

7. Optionally add a Description for the event.

8. Click Submit and make sure the new event is checked to start tracking.

For more information, refer to Viewing Metrics with Insights.

With the Builder Gen 2 SDKs, you can use Builder's event tracking module to:

  • track events
  • track data retrieval
  • handle API requests

You can create event objects, check if tracking is enabled, and send the event data to a tracking API.

To track and send the event data to the tracking API, use the track() function with an object containing the type property.

The type property specifies the type of event you want to track. It can be one of the predefined values:

  • impression
  • conversion
  • click
  • some-custom-event.

You can choose the appropriate type based on the event you want to track. For example:

// Make sure you're using a Gen 2 SDK
import { track } from '@builder.io/sdk-vue'

track({
  type: 'impression' | 'conversion' | 'click' | 'some-custom-event',
  apiKey: YOUR_API_KEY
});

enterprise plans

You can incorporate custom events into your custom dashboards by modifying your dashboards' SQL queries. For more information, see Programming Custom Dashboards.

Was this article helpful?

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Newsletter

Get the latest from Builder.io

By submitting, you agree to our Privacy Policy