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
Go to solution Solved by foleyatwork,

Question

I'm want to use Google Analytics to track conversions from my Squarespace 6 site - those conversions being a completed form on the site - but cannot find a way to include the code in the submission button or the form submitted page.

Does anyone know of a workaround to allow me to track completed forms?

Edited by erich
retag
Link to post
  • 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 post
  • 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 post
  • 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 post
  • 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 post
  • 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 post
  • 1

This does not work with google adwords campaigns.

Any proof it does?

Since squarespace is so focused on small businesses, wouldn't this be a core feature? Tracking money spent to drive traffic that converts to my new sqaurespace contact form?

Link to post
  • 1

Thanks Alex, could you tell me where I would find the code to put into the Post-Submit HTML box?

I have added the HTML that Google Adwords provides but this does not work.

:)

Link to post
  • 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 post
  • 1

Thanks for that work-around. Creating a separate Thank You page for my forms seems to have worked great in terms of tracking them as goals in Google Analytics. And I like the user experience better this way as well. So thanks again - much appreciated!

Link to post
  • 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 post
  • 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 post
  • 1

For anyone else struggling with getting the new Thank You page to come up-Make sure that you aren't logged in as administrator - it won't work if you are logged in.

Link to post
  • 0
Guest

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 post
  • 0
Guest

How does one set this up in the google conversion tracking?

Link to post
  • 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 post
  • 0

ok, so @foleyatwork i just tried this (adding the google adwords script to the 'post-submit html' on the contact's advance form. @webbroi said this works).

we'll see, but it looks like the code is there on the first page load too. i believe that will trigger a google adwords 'conversion' as soon as the contact page is loaded. correct me if i'm wrong.

thanks!

Edited by odower
Link to post

Create an account or sign in to comment

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


×
×
  • Create New...