Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 16

How can I track form submissions in Google Analytics?


edwinorange

Question

  • Answers 54
  • Created
  • Last Reply

Top Posters For This Question

Recommended Posts

  • 4

Paste the following code into the footer code injection of your site.


<script>
 Y.use('node', function() {
   Y.on('domready', function() {
     Y.all('.form-block').each(function(n) {
       var d = n.getData('block-json');
       d = Y.JSON.parse(d);
       n.one('form').on('submit',function() {
         _gaq.push(['_trackEvent', d.formName + ' Submission', 'Form Submission', 'Submit']);
       });
     });
   });
 });
</script>

This is a one step process. Once you paste this code in your footer, each form will be tracked automatically with the form name in Google Analytics.

Please post any feedback as a comment here. If there is a bug I will try and fix it.

Also, please note this is not supported by Squarespace, even though I am a Squarespace employee. Support won't be able to help you out, but I will do my best to make sure this code works and stays up-do-date.

Edited by foleyatwork

Developer Evangelist at Squarespace.

Link to comment
  • 12

The easiest method I have found, also has some benefits by using a /Thank-you page.

  1. Create a new /Thank-You page in Squarespace
  2. Edit your Form on your /Contact page. Under advanced add this simple script to the Post Submit HTML

window.location.replace("/thank-you"); (note: add the script beg and end tags)


<script> window.location.replace("/thank-you"); </script>

  1. Create a Google Analytics Goal for the /Thank-you page

This method also lets you track the /thank-you page in page views, to help troubleshoot issues. We also added a redirect to the homepage. You can do all sorts of thing with your /thank-you page pushing your users to other content etc.

Update: I have confirmed this still works, with standard "stock" squarespace GA implementation. Not tested with Universal via code injection.

Edited by webbroi
Link to comment
  • 3

THIS IS FOR ADWORDS, NOT ANALYTICSYou can simply paste the Google Adwords code into the Post-Submit HTML box under Edit Form -> Advanced. e.g:

?value=0&label=7opUCNj90wQQmJWz6AMX&guid

This script will be fired only on successful submission of the form.

See My new Answer Related to a simple method related to creating a /Thank-You page.

Edited by webbroi
Link to comment
  • 2

jQuery code injection will do the job. Just inject the following code on your form page, replacing the category and action with your own labels.


    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
   <script type="text/javascript">

   $(document).ready(function(){
       $('input.button').click(function() {
           window.setInterval(foo, 100);
       });
   });

   function foo(){
           if($(".form-submission-text").is(':visible')){
               _gaq.push(['_trackEvent', 'YourForm', 'Submission']);
           }
   }

   </script>

Edited by edwinorange
Link to comment
  • 2

Has anyone figured out a solution to this yet?

For the record, I added the code listed above to the Post-Submit HTML box in the form settings on one of my site's pages...and also updated the Category / Action / Label information, and it did not successfully send any Event information to Google Analytics.

Figuring out how to track form submissions as trackable Events in Google Analytics is a very important part of my site's reporting so I would greatly appreciate any help in figuring this one out! Cheers!

Link to comment
  • 1

Can someone please confirm whether webbroi's answer above will work with Google's Universal Analytics? I have UA running on my Squarespace site and just want to make sure I'll be able to track form submissions by inserting the following code into my form's Post-submit HTML box?

Thanks!

Link to comment
  • 1

I couldn't get either of the code snippets offered here to work. But they would only work with GA Classic. I was able to get conversion tracking set up successfully with Google Tag Manager, GA Universal, and minimal code injections.

I described the method in reply to another post:https://answers.squarespace.com/questions/60229/how-can-i-track-form-submissions-with-google-tag-managergoogle-analytics-in-v7.html#answer-121964

( @foleyatwork )

Edited by scgarris
Initial Revision
Link to comment
  • 1

Hey Squarespace. Is this really the best solution? I continue to get emails of people asking abou this. My solution below works, and got 10 upvotes vs the 3 on this "best answer" Its really a bit confusing to me why this is not prioritized as a feature. Tracking goals should be at the top of the feature list for any webmaster or company with a website big or small.

Link to comment
  • 1

The easiest most accurate way I have found to track form submissions in Analytics is to create a redirect to a thank you page or enquiry confirmation type page, using a script in the Post Submit HTML. All you do is have to then set up a new goal in Analytics and you can start tracking your form submissions.

I have recently put together a whole video walkthrough on the topic that you may find useful:http://www.atomicmarketing.co/blog/conversion-tracking-squarespace-google-analytics

Digital marketing consultant at Atomic Marketing. I write about SEO, web design & Squarespace. Passionate about travel and entrepreneurship.

Link to comment
  • 1

If anyone comes across this, our team recently added support for Squarespace sites.

BigPicture.io (https://.bigpicture.io) is a point-and-click event tracking tool. We make it easy to setup tracking and integrate with hundreds of tools without having to write a line of code.

We have a ton of integrations including GA, Facebook, and ActiveCampaign.

Link to comment
  • 0

Hello-

Would this also work for tracking e-commerce conversions? I am searching for a way to track conversions from Adwords, etc through to purchase. There is currently no way to inject code into the completed sale page.

Any help is appreciated.

Andy

Link to comment
  • 0

I am unable to get this to work.

Looking at the page elements in the browser inspector window I do not see the formName property in the form-block, and thus when the form 'submit' event fires, d.formName is undefined. My form-block looks like this:


<div class="sqs-block form-block" data-block-json="{"useLightbox":false,"lightboxHandleText":"Get Info","formId":"51d4498ee4b03b50e2322d8c"}" data-block-type="9" id="block-6d99117d0a0ea3afbb33">

is there another way to get the formName from the formId?

Edited by Mark L
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...