Made in Builder.io

Visual Copilot Livestream | Dec 6 @10am PST

Introducing Visual Copilot: Figma to code with AI

Builder.io and Figma
Talk to Us
Product
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.


Looking to hire a third party to help with your project?

Submit a project request and our partnerships team will reach out to connect you with an Expert from our partner ecosystem.

Connect with us

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

Get the latest from Builder.io

Developer Newsletter

Latest tips, tricks, and news for frontend developers from our blog

Product Newsletter

Latest features and updates on the Builder.io platform

By submitting, you agree to our Privacy Policy

Product

Visual Copilot Beta

Visual Headless CMS

Integrations

What's New

Company

About

Careers

Developers

Builder for Developers

Documentation

Devtools

Try Builder Playground

OPEN SOURCE

Builder

Mitosis

Qwik

Partytown

Solutions

Ecommerce

Marketing Sites

Landing Pages

Mobile Apps

Multi-brand

Headless CMS

Product

Visual Copilot

Visual Copilot Beta

Visual Headless CMS

Integrations

What's New

Company

About

Careers

Developers

Builder for Developers

Documentation

Devtools

Try Builder Playground

OPEN SOURCE

Builder

Mitosis

Qwik

Partytown

Builder.io logo

Visually build and optimize digital experiences on any tech stack. No coding required, and developer approved.

Get Started

Log In

Product

Features

Pricing

Integrations

React.js

Next.js

Gatsby

Angular

Vue

Nuxt

Hydrogen

Salesforce

All Integrations

Use Cases

Product

Features

Pricing

Product

Visual Headless CMS

Integrations

What's New

Company

About

Careers

Developers

Builder for Developers

Developer Docs

Open Source Projects

Performance Insights

Developers

Builder for Developers

Documentation

Dev Tools

Try Builder Playground

Open Source

Builder

Mitosis

Qwik

Partytown

Resources

Documentation

Blog

Community Forum

Templates

Partners

Submit an Idea

Solutions

Ecommerce

Landing Pages

Multi-brand

Headless CMS

Popular Guides

SaaS Marketing Site Ebook

Composable Commerce Ebook

Headless CMS Guide

Landing Pages

Headless CMS

Headless Storefront

Customer Showcase

Customer Success Stories

Frameworks

React

Next.js

Qwik

Gatsby

Angular

Vue

Nuxt

Hydrogen

All Integrations

CMS

React

Integrations

React.js

Next.js

Gatsby

Angular

Vue

Nuxt

Hydrogen

Salesforce

All Integrations

Resources

Blog

Knowledge Base

Community Forum

Partners

Performance Insights

Templates

Success Stories

Showcase

Integrations

React.js

Next.js

Gatsby

Angular

Vue

Nuxt

Hydrogen

Salesforce

All Integrations

Resources

Blog

Knowledge Base

Community Forum

Partners


Templates

Success Stories

Showcase

Use Cases

Company

About

Careers

Resources

Blog

Knowledge Base

Community Forum

Partners

Performance Insights

Templates

Success Stories

Showcase

© 2023 Builder.io, Inc.

Security

Privacy Policy

SaaS Terms