/** * Contador de simpatizantes Santiago Paz - Región Piura * Base inicial: 2730 + registros reales de Forminator */ function sp_region_piura_get_simpatizantes_count() { global $wpdb; // Número base de campaña $base_inicial = 2730; // 0 = cuenta todos los envíos de Forminator. // Más adelante podemos poner aquí el ID exacto del formulario. $form_id = 0; $table = $wpdb->prefix . 'frmt_form_entry'; // Verifica si existe la tabla de Forminator $table_exists = $wpdb->get_var( $wpdb->prepare("SHOW TABLES LIKE %s", $table) ); if ($table_exists !== $table) { return $base_inicial; } if ($form_id > 0) { $real_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE form_id = %d", $form_id ) ); } else { $real_count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" ); } return $base_inicial + $real_count; } function sp_region_piura_ajax_simpatizantes_count() { wp_send_json_success([ 'count' => sp_region_piura_get_simpatizantes_count() ]); } add_action('wp_ajax_sp_region_piura_count', 'sp_region_piura_ajax_simpatizantes_count'); add_action('wp_ajax_nopriv_sp_region_piura_count', 'sp_region_piura_ajax_simpatizantes_count'); function sp_region_piura_counter_script() { ?> document.addEventListener("DOMContentLoaded", function () { var leadSent = false; function sendLeadEvent() { if (leadSent) return; if (typeof fbq === "function") { fbq("track", "Lead", { content_name: "Me uno de corazón", content_category: "Registro simpatizante", campaign: "Santiago Paz Región Piura" }); leadSent = true; console.log("Meta Pixel Lead enviado: Santiago Paz Región Piura"); } } /* Evento estándar de Forminator */ if (window.jQuery) { jQuery(document).on("forminator:form:submit:success", function () { sendLeadEvent(); }); } /* Respaldo: detecta mensaje de gracias del formulario */ var observer = new MutationObserver(function () { var bodyText = document.body.innerText.toLowerCase(); if ( bodyText.includes("gracias") || bodyText.includes("thank you") || bodyText.includes("enviado correctamente") || bodyText.includes("formulario enviado") ) { sendLeadEvent(); } }); observer.observe(document.body, { childList: true, subtree: true }); });

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

1 thought on “Hello world!”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top