Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting a Google Analytics event inside an Ajax form
    primarykey
    data
    text
    <p>I am trying to set a Google Analytics event on a lightbox contact form of a WP plugin.</p> <p>I have added the onSubmit call inside the and although it renders well without problem, the events are not logged into Analytics</p> <pre><code>&lt;form action="#" method="post" class="modal-contact_form" onSubmit="_gaq.push(['_trackEvent', 'Contact V1', \'&lt;?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ?&gt;', '1']);"&gt; </code></pre> <p>The event seems not to log in, because there's a new Thank You lightbox window which appears after you hit Send on Contact form</p> <p>This is teh original code of the Thank you lightbox window</p> <pre><code> $.post( modal_contact_params.ajax_url, data, function( response ) { if ( response == "SUCCESS" ) { $('#facebox .content form.modal-contact_form').slideUp(); $('#facebox .notice').remove(); var agent_name = jQuery("#ninety_mcf_user_name").html(); if(agent_name=='This Agent'){ $('#facebox .modal-contact_messages').html('&lt;div class="notice success"&gt;&lt;div&gt;&lt;p&gt;&lt;strong&gt;' + modal_contact_params.i18n_sent + '&lt;/strong&gt; ' + modal_contact_params.i18n_thanks + '&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;' ); } else { $('#facebox .modal-contact_messages').html('&lt;div class="notice success"&gt;&lt;div&gt;&lt;p&gt;&lt;strong&gt;' + modal_contact_params.i18n_sent + '&lt;/strong&gt;Thanks, your email has been sent to '+agent_name+'&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;' ); } } </code></pre> <p>I am trying to insert the _gaq.push Event call at the end of Success lightbox but I can't make it</p> <p>I have tried all sorts of combinations and none of them render, as they all produce errors on GA Debug console in Chrome</p> <p>One of my many different tries</p> <pre><code>&lt;/div&gt;' + { _gaq.push(['_trackEvent', 'Contact V1', 'Send', '1']); } +'' ); </code></pre> <p>Thanks and I hope it's easy enough for SO gurus to help me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload