Themeforest

Adding google event tracking to the contact form

Event tracking for google analytics can easily be added to the contact form using jQuery to initiate the event tracking code when the form submit button is clicked:

$('.slick-form .btn-submit').click(function(){
   _gaq.push(['_trackEvent', 'category', 'action', 'opt_label']);
});

Change the 3 parameters according to your requirements:

category (required)

The name you supply for the group of objects you want to track.

action (required)

A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.

label (optional)

An optional string to provide additional dimensions to the event data.

2 Comments

  • hi, im tryieng to install your contact form with google analytics but i don´t know where i have to install the code you say here.
    Thanks

    Great plugin!

    • Hi,

      The code can basically go anywhere as long as it’s after the jquery library has loaded.

      If your theme has a generic jquery file, where all of the theme’s scripts are kept I would suggest adding it to there

Leave a comment

To add code to your comments wrap the code text in [text][/text] tags