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.
Event tracking with the PHP API wrapper is one of many ways 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 your ActiveCampaign. 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.
To learn more, here is an overview of Event Tracking and how to turn it on in your ActiveCampaign account.
In this article, we'll discuss how to set up Event Tracking with the API wrapper.
Setting up Event Tracking with the API wrapper
First, you'll need to define your API credentials:
define("ACTIVECAMPAIGN_URL", "https://ACCOUNT.api-us1.com");define
("ACTIVECAMPAIGN_API_KEY", "3693354bb1...04c2d126b9c");require_once
("../activecampaign-api-php/includes/ActiveCampaign.class.php");$ac =
new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY)
Then set up your tracking details:
$ac->track_actid = "764325673";$ac->track_key = "oy5tbe34c564...
69079d18abc";
You can find the account ID and key values on the Website > Site Tracking page. Click the link that says “Event Tracking API":
If you want to associate an email address with the event, add it like this:
$ac->track_email = "test@test.com";
If you don’t associate an email address, the event will still be added and available for creating a segment.
Next, set your event data and submit the request:
$post_data = array("event" => "event_name1", // "event_name2", etc.
"eventdata" => "event_value",);$response = $ac->api("tracking/log",
$post_data);
The response will look something like this:
stdClass Object([success] => 1[message] => Event spawned[http_code]
=> 200)
Now event data will appear in your contact's Activity Stream on the Contact Record and you'll be able to use Event Tracking data to create segments.
Here is an overview of Event Tracking to learn more.