Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fbtrigger = false;
- const observer = new MutationObserver(() => {
- const element = document.getElementsByClassName('forminator-success')[0];
- if (element && element.style.display === 'block') {
- fbtrigger = true;
- proxy.value = fbtrigger;
- }
- });
- observer.observe(document.body, { childList: true, subtree: true });
- const proxy = new Proxy({ value: fbtrigger }, {
- set: function(target, prop, value) {
- if (prop === 'value' && target.value !== value) {
- target.value = value;
- if (value === true) {
- //fb lead event
- fbq('track', 'Lead');
- //ga4 lead event
- gtag("event", "generate_lead", {
- currency: "EUR",
- value: 1,
- lead_source: "Forminator Lead",
- });
- }
- }
- return true;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement