Example Usage of

Add event tracking event name and value

Description: Add tracked event (name and value) to the system (globally). Make sure to enable event tracking before making this call (events added with event tracking disabled will not be saved).
HTTP method: POST
Supported output formats: json
Requires authentication: Yes
* indicates requirement. Underlined params include in URL, otherwise as part of the post body. POST data must be formatted as
Content-Type: application/x-www-form-urlencoded
. We don't accept any other input formats like JSON.
Variable Description
api_key*Your API key
actid*Your unique tracking account ID (can be found on the Integrations page)
key*Your unique tracking event key (can be found on the Integrations page)
event*The event name you want to add. Example: 'my_custom_event'
eventdataThe event value (related to the event name). Example: '12345'. (Note: if you don't include this parameter it will still save the event name.)
visitSee below example for the data you can include here.
Example response:
Variable Description
successWhether or not the request was successful. Example: 1 (successful) or 0 (not successful)
messageThe response message. Example: "Event spawned"

PHP Example

This is an example of using the track_event_add call with PHP. You can replicate the same idea in virtually any other programming language. The example shown is using serialize as the output format. You can change that to XML or JSON if you would like.


// Set up an object instance using our PHP API wrapper.
define("ACTIVECAMPAIGN_URL", "https://{ACCOUNT}");

$ac->track_actid = "1111111"; // your unique tracking account ID (found on the Integrations page).
$ac->track_key = "hus7dasty..."; // your unique event key (found on the Integrations page).
$ac->track_email = "[email protected]"; // (optional) contact email address to associate the event with.

$post_data = array(
	"event" => "my_custom_event",
	"eventdata" => "12345",
	// any extra (optional) visit data to include?
	"visit" => array(
			"url" => "",
			"referrer" => "",
			"ip4" => "",
			"ip6" => "",
			"ua" => "",
			"browser" => "",
			"platform" => "",
			"device" => "",
			"utm_source" => "",
			"utm_campaign" => "",
			"utm_medium" => "",
			"utm_term" => "",
			"utm_content" => "",
$response = $ac->api("tracking/log", $post_data);

echo "<pre>";
echo "</pre>";


Questions? Discuss this API call in our developer forum