An overview of Event Tracking

Event tracking is an advanced feature and requires working with our open API and knowledge of programming language.

Event Tracking is a flexible feature that allows you to collect data on a wide variety of contact behavior. You can create an event for any activity on your website or app and assign it a value. As you begin to capture event data and send it your ActiveCampaign account, you can use it to improve your marketing and sales processes as well as use it to trigger automations, create segment conditions, and personalize campaigns.

In this article, we'll discuss:

Event Tracking vs. Site Tracking

Event Tracking is flexible and lets you track virtually any contact behavior that you define on your website. For example, you can track video views, button clicks, orders, log ins, in-app behavior, and more. With Event Tracking, you'll need to create customized code for each event you'd like to track on your website. 

Site Tracking is a type of Event Tracking. It simply tracks webpage visits made by contacts. With Site Tracking, we provide you with a snippet of code that you paste into every page of your site. If you only need to track page visits, we recommend this option. Learn more about Site Tracking here.

How Event Tracking Works

Event Tracking is an advanced feature: you'll need to be familiar with a programming language to set it up on your website or app and you can use any programming language you prefer. If you do not know any programming languages, you can work with someone on your team who does, or you can hire an ActiveCampaign Certified Consultant to set it up for you.

In order to use Event Tracking, you'll need to:

  1. Turn on Event Tracking in your ActiveCampaign account.
  2. Use a programming language (of your choice) on your site to capture the following four data points: Who (contact's email address) performed the event (defined by you) consisting of a value (defined by you) and when the event happened.
  3. Use our open API to send us the event information.

When this information is sent, we'll match the email address of the contact who took the defined action and match it to the email address of a contact in your ActiveCampaign account. We'll then attribute that event to the contact. If the event does not yet exist in your ActiveCampaign account, we'll display it on your Settings > Tracking page and it will be made available in the segment builder. If a contact does not exist in your ActiveCampaign account, the contact record will not be created and the event will not be added.

Turning Event Tracking on

1. Click "Settings" located in the lower left-hand corner of your ActiveCampaign account.

2. Click "Tracking" located in the left-side menu.

3. Click the red Event Tracking "Status" toggle to turn it on:

The Event Key will appear in the Event Key field (blurred out in the image below).

You will need to pass us this key when you call the API in order to send us the event data you've captured on your site. To see the Event Key in example code, click the "Event Tracking API" link provided on the Settings > Tracking page (more information below).

Events will be listed in this box as well as in the segment builder as contacts complete them. 

4. Click "Save Settings."

Event Tracking example code

The code you use will vary depending on the event you are tracking and other factors. You can generate example code to use as a starting point. To generate example code, click the "Event Tracking API" link.

A modal window will open and provide code that includes your account ID and key:

An Event can be triggered by using POST to send data to http://trackcmp.net/event. This can be done in virtually any programming language. Below is an example of how this could be done using PHP.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://trackcmp.net/event");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
"actid" => 23033,
"key" => "c12973b078007927842301eff932e7d78b74b3e",
"event" => "YOUR_EVENT",
"eventdata" => "ANY_DATA",
"visit" => json_encode(array(
// If you have an email address, assign it here.
"email" => "",
)),
));

$result = curl_exec($curl);
if ($result !== false) {
$result = json_decode($result);
if ($result->success) {
echo 'Success! ';
} else {
echo 'Error! ';
}

echo $result->message;
} else {
echo 'CURL failed to run: ', curl_error($curl);
}

Event Tracking with our PHP API wrapper

Event Tracking with the PHP API wrapper is one of many ways you can use to send event tracking data to your ActiveCampaign account. Once you've written the code on your site to define and capture events, you can use the wrapper to send the event data to us. Using an API wrapper makes sending event data to your account easier—wrappers handle the API connection and specific API calls as simple functions. This saves you time from having to create the API connection and calls from scratch.  

Read more information on Event Tracking with the PHP API wrapper.

Have more questions? Submit a request