Tatiana Santos
Tatiana Santos

Reputation: 59

Show pop-up form when visitor comes from utm

I have a problem with a wordpress site with elementor pro that I can't solve.

Objective:
When the person comes from a Google Ads UTM a specific popup appears with the Google Ads Form, if they come from organic another popup opens with another form.

Specifications / Elements:
Wordpress site with the Pro element, and popups from the element itself.

2 different popups, each with a specific form.

What was done:

  1. Installed the “Header Footer Code Manager” plugin
  2. Added the JavaScript code, in the footer and header, to appear in “site wide”:
  3. Tests were carried out, and several versions of the code, but only the organic popup appeared, both with the google Ads UTM and the organic one.
document.addEventListener("DOMContentLoaded", function() {
  getURLParameter(name) {
    return new URLSearchParams(window.location.search).get(name);
  } 

  const utmSource = getURLParameter('utm_source'); 

  // IDs dos popups no Elementor 
  const popupGoogleId   = "19330"; // ID do popup para Google Ads 
  const popupOrganicoId = "16228"; // ID do popup para tráfego orgânico 

  // IDs dos formulários do Gravity Forms 
  const formGoogleId   = "38"; // ID do formulário para Google Ads 
  const formOrganicoId = "19"; // ID do formulário para tráfego orgânico 

  // Exibir o popup correspondente com base no parâmetro UTM 
  if (typeof elementorPro !== "undefined" && elementorPro.modules.popup) {
    if (utmSource === 'google_ads') {
      // Abre o popup para Google Ads      
      elementorPro.modules.popup.showPopup({ id: popupGoogleId });
    } else {     
      // Abre o popup para tráfego orgânico      
      elementorPro.modules.popup.showPopup({ id: popupOrganicoId });
    }
  }
});

Any idea what else could be done?

Upvotes: -1

Views: 56

Answers (0)

Related Questions