$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" => "66543352", "key" => "71ab8fa181437d0f65be60effabb30398a13574d", "event" => "video_10Fermentos", "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); } $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" => "66543352", "key" => "71ab8fa181437d0f65be60effabb30398a13574d", "event" => "video_25Fermentos", "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); } $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" => "66543352", "key" => "71ab8fa181437d0f65be60effabb30398a13574d", "event" => "video_50Fermentos", "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); } $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" => "66543352", "key" => "71ab8fa181437d0f65be60effabb30398a13574d", "event" => "video_90Fermentos", "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); } function trackActiveCampaignEvent(eventData) { var request = new XMLHttpRequest(); request.open("POST", "https://YOUR_API_ENDPOINT_URL/api/3/events"); request.setRequestHeader("Content-Type", "application/json"); request.setRequestHeader("Api-Token", "71ab8fa181437d0f65be60effabb30398a13574d"); var data = JSON.stringify({ "event": "Video_Watched", "eventdata": eventData, "email": "USER_EMAIL" }); request.send(data); } // Este ejemplo se activaría cuando el usuario haya visto el 50% del video: if (porcentajeVista == 50) { trackActiveCampaignEvent("Visto 50%"); }