I use Squarespace to build fast and beautiful marketing sites to attract customers to any product or service. Usually, these marketing sites include a contact form which you can use to track leads.
Squarespace offers poor documentation on how to track these form submissions with Google Tag Manager. I’ll explain how to do it assuming you already have an account with Squarespace, Google Adwords, Google Analytics and Google Tag Manager.
First, copy your Google Tag Manager code into Squarespace:
- Login into your Squarespace account.
- Click on “Settings”.
- Click on “Advanced”.
- Click on “Code Injection”.
- Copy your Google Tag Manager code in the header section.
Now, let’s copy the following the code in the footer section.
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> var formSubmitted = false; $(document).ready(function(){ $('input.button').click(function() { window.setInterval(checkFormSubmission, 100); }); }); function checkFormSubmission(){ if(($(".form-submission-text").is(':visible')) && (formSubmitted == false)){ dataLayer.push({'event': 'formSubmission'}); formSubmitted = true; } } </script>
This code checks if the form is submitted without any errors and fires an event called formSubmission. We need to create a trigger in Google Tag Manager that fires when the formSubmission event is fired. That’s how we’ll track when a form is submitted.
- Go to the Triggers menu on your Google Tag Manager account.
- Click on “New”
- Write a name for this trigger. It could be “Web Contact Form Submission”.
- Select the “Custom Event” event.
- On the event name field write “formSubmission”.
- Click on “Create Trigger”.
Track contact form submissions on Google Analytics
- Go to the Tags menu on your Google Tag Manager account.
- Click on New.
- Write a name for this tag.
- Select product “Google Analytics”.
- Choose tag type “Universal Analytics”.
- Write you Tracking ID on the given text field (this is id is given by Google Analytics). Select “Event” in the Track type list and then click on Continue.
- On the Fire On step click on “More” and select the trigger you just created from the list and click Save.
- Click on”Create Tag.
That’s it. Preview your tag to see check that everything is working and publish your changes. You can now check for this form submission event in your Google Analytics account.
Track contact form submissions on Google Adwords
- Go to the Tags menu on your Google Tag Manager account.
- Click on New.
- Write a name for this tag.
- Select product “Google Adwords”.
- Select “Adwords Conversion Tracking”.
- Fill at least the Conversion ID and name fields (if you have not created any conversions, follow this link and learn how to do it https://support.bigcommerce.com/articles/Public/How-do-I-add-Google-Adwords-Conversion-Tracking) and then click on Continue.
- Write you Tracking ID on the given text field (this is id is given by Google Analytics). Select “Event” in the Track type list and then click on “Continue”.
- On the Fire On step click on “More” and select the trigger you just created from the list and click Save.
- Click on “Create Tag”.
That’s it. Preview your tags to check that everything is working and publish your changes. Feel free to ask any questions in the comments section.
Special thanks to:
http://www.silvabokis.com/squarespace-tips/tracking-squarespace-form-submissions-in-google-analytics-using-jquery
Hey guys,
Thanks for the great read!
I wanted to get in touch with you to let you know that I have just published a similar article on how to track form submissions using Google Analytics. I think you’ll enjoy it and it may make a nice addition to your post!
I would be grateful if you checked out, I would love to get your feedback on it:
http://www.atomicmarketing.co/blog/conversion-tracking-squarespace-google-analytics
Let me know what you think 🙂