ActiveCampaign / activecampaign-api-php

MIT License
115 stars 76 forks source link

Event Tracking (tracking/log) doesn't works #31

Closed dieend closed 8 years ago

dieend commented 9 years ago

Why this doesn't works? (the event not showing in user activity)

$activeCampaign->track_actid = $this->trackId;
$activeCampaign->track_key = $this->trackKey;;
if ($email) {
    $activeCampaign->track_email = $email;
}
$request = [
    'event' => 'login',
    'visit' => [
       "url" => 'http://www.example.com'
    ]
];

$response = $activeCampaign->api("tracking/log", $request);
if (!$response->success) {
     // it's true
}

but this does works? (the event shows up in user activity)

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://trackcmp.net/event");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
        "actid" => $this->trackId,
        "key" => $this->trackKey,
        "event" => "login",
        "visit" => json_encode([
                        "email" => $email,
                    ],
                ))
        );
mthommes commented 9 years ago

The first example you provided should just have event and eventdata in $request, with a string value for both. eventdata is optional. Our event tracking feature doesn't currently accept a collection of data (as you have an array there).

It seems like you are trying to track a page visit (our "site tracking" feature) using our event tracking mechanism, which is not possible. Site tracking uses a different endpoint, and relies on a cookie being included with the request.

Hope that helps! Let us know if not.

dieend commented 8 years ago

I'm using wrong id (missing one character in the variable). My bad.

But it should not return response success though. Maybe return 401 with message invalid actid.