简体   繁体   中英

Google analytics event tracking on javascript form

How can I add this "_gaq.push(['_trackEvent'" code to tell google to track form submit event? This is not working right now!

I want to track only successful form subbmit events.

submitHandler: function(form) {
        $('#LoadingLizings').show();
        $(form).ajaxSubmit({
            type:"POST",
            data: $("#lizings").serialize(),
            url:"assets/process_lizings.php",
            cache: false,
            success: function() {

                _gaq.push([‘_trackEvent’, ‘form’, ’submitted’, ’lizings_form’,, ’true’]);

                $('#lizings :input').attr('disabled', 'disabled');
                $('#lizings_form').fadeTo( "slow", 0.05, function() {
                    $('#LoadingLizings').hide();
                    $('#LizingsSuccess').fadeIn();
                });
            },
            error: function() {
                $('#lizings_form').fadeTo( "slow", 0.05, function() {
                    $('#LoadingLizings').hide();
                    $('#LizingsError').fadeIn();
                });
            }
        });
    }

You have an issue with the quotes for your code, assuming that is the exact code you have on your site. You're using smart quotes, which should be replaced by single quotes ('), like this:

_gaq.push(['_trackEvent', 'form', 'submitted', 'lizings_form']);

Also, by default, events are interactive, so you don't need the last "true" parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM