Support for

Adding event tracking to w3shop contact form

Alistair Wilson
by Alistair Wilson 6 years ago
 

Google Events tracking can be used to track specific ways users interact with a website and perform an event

This can be used for goals and tracking conversions that aren't just e-commerce
A conversion can be filling in a contact form, clicking a phone number link or emailing.

Details on Google Event tracking can be found here: https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Getting started with event tracking

1) Ensure Google Analytics has been added to your w3shop

2) Add this header snippet to your contact form

<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
jQuery(document).ready( function($) {
document.getElementById("contact-submit").addEventListener("click", function( event ) {
    ga('send', 'event', 'w3shop contact Form','Sent OK','Contact Us');
}, false );
});
</script>

Change the part in bold for the event name

3) Test by submitting the contact form

Note It will take time for the event to get logged in Google Analytics

 

 
 
 
 

All content is (c) Nettl Systems Limited, 2024 and may not be used, copied or distributed without permission.