Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
Track Event for the Youtube video's event by using Javascript into ActiveCampaign

I want to trigger the event for the Youtube video in the Wordpress when the video ends. And the event will be visible in the ActiveCampaign contact's activity.

But when I run this code, it does not show anything in my ActiveCampaign's contact activity.

What is the problem with my code? Or any suggestion?

Thank you.

// create a short function to fire the event tracking snippet. 
function VideoPlayed() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      console.log("Recorded Played Video event");
      console.log(this.responseText);
    } else {
      console.log(this.responseText)
    }
  };
  var actid = "ACTID"; // your ActiveCampaign id. You can get this from your AC settings 
  var eventKey = "Event key"; // your event key, also in AC settings
  var event = "Played Video" // whatever event you want to track. It would be a better idea to "DRY" this up, and pass the event name as a parameter into the function, so you can track any event with one function
  var visit = {
    email: "Email" // the user's email address
  };
  var eventString = "actid=" + actid + "&key=" + eventKey + "&event=" + event + "&visit=" + encodeURIComponent(visit) + "&eventdata" + eventData;
  xhttp.open("POST", "https://trackcmp.net/event", true);
  xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhttp.send(eventString);
}


var vid = document.getElementById("embed_video");
var i;
for (i = 0; i < vid.length; i++) {
 vid[i].onended = function() {
   VideoPlayed(); // <-- run the function once our audio has finished playing. 
   
   alert("The video has ended");
 };
};

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda