edwinorange Posted March 27, 2013 Share Posted March 27, 2013 (edited) 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 July 27, 2016 by erich retag Tyler West, flow2000, everydayadventures and 8 others 11 Link to comment
edwinorange Posted April 4, 2013 Author Share Posted April 4, 2013 (edited) 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 April 4, 2013 by edwinorange Link to comment
Solution foleyatwork Posted April 17, 2013 Solution Share Posted April 17, 2013 (edited) 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 April 17, 2013 by foleyatwork Developer Evangelist at Squarespace. Link to comment
Guest Posted May 8, 2013 Share Posted May 8, 2013 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
foleyatwork Posted May 9, 2013 Share Posted May 9, 2013 No, this particular piece of code will not work for ecommerce. You can always post a separate thread asking about that. Developer Evangelist at Squarespace. Link to comment
Guest Posted June 18, 2013 Share Posted June 18, 2013 How does one set this up in the google conversion tracking? Link to comment
Mark L Posted July 3, 2013 Share Posted July 3, 2013 (edited) 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 July 3, 2013 by Mark L Link to comment
foleyatwork Posted July 3, 2013 Share Posted July 3, 2013 It might be because you're using the lightbox. The script I developer was on a form without the lightbox. Not really sure. You got a link? Developer Evangelist at Squarespace. Link to comment
voyage Posted July 8, 2013 Share Posted July 8, 2013 Does anyone know which method is best to use? Link to comment
Guest Posted August 18, 2013 Share Posted August 18, 2013 Hi Kevin, I tried the code but for some reason GA doesnt track submissions yet. What would you enter in GA targets? Thanks a lot, Martin Link to comment
Guest odower Posted September 13, 2013 Share Posted September 13, 2013 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 comment
avsmithy Posted October 2, 2013 Share Posted October 2, 2013 I get the same problem as Mark (above), looks like formName has been removed from the JSON (inc. on non-lightbox forms). You can use formId instead. Link to comment
webbroi Posted October 11, 2013 Share Posted October 11, 2013 (edited) 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: 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 November 6, 2013 by webbroi Squarewebsites.org Plugins. Webbroi.com Growth Marketing Link to comment
Guest odower Posted October 11, 2013 Share Posted October 11, 2013 (edited) 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 October 11, 2013 by odower Link to comment
foleyatwork Posted October 12, 2013 Share Posted October 12, 2013 Hey Guys, This answer was submitted before you were allowed to submit HTML into the post-submit field. I'm going to take another look at this next week and figure out the best way to do it now. Developer Evangelist at Squarespace. Link to comment
Guest odower Posted November 6, 2013 Share Posted November 6, 2013 hey @foleyatwork did you figure anything out? right now i'm just wasting $ driving traffic that I can track if they actually submitted a contact form. Link to comment
avsmithy Posted November 6, 2013 Share Posted November 6, 2013 @odower - @webbroi is correct. Paste the script in post-submit HTML. Link to comment
sean88 Posted January 9, 2014 Share Posted January 9, 2014 Is there a definitive answer to this question yet? foleyatwork did you come up with something? :) Link to comment
sean88 Posted January 9, 2014 Share Posted January 9, 2014 Is there a definitive answer to this question yet? foleyatwork did you come up with something? :) Link to comment
sean88 Posted January 9, 2014 Share Posted January 9, 2014 Hi foleyatwork, did you manage to get anywhere with this? Or has anyone else posted a successful workaround? thanks :) Link to comment
avsmithy Posted January 9, 2014 Share Posted January 9, 2014 This is the best method for tracking for submissions, I can confirm it works. Link to comment
sean88 Posted January 9, 2014 Share Posted January 9, 2014 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 comment
jeremyjaytaylor Posted January 16, 2014 Share Posted January 16, 2014 I'm afraid I don't understand. Once I inject the code into my footer, where do I go in google Analytics to see the submission tracking? I don't see it in my dashboard... Link to comment
jeremyjaytaylor Posted January 16, 2014 Share Posted January 16, 2014 I'm afraid I don't understand. Once I inject the code into my footer, where do I go in google Analytics to see the submission tracking? I don't see it in my dashboard... Link to comment
licnyguy Posted January 19, 2014 Share Posted January 19, 2014 Hello, I'm interested in using this code snippet in the footer of my site to track form submissions, but I wanted to check first to make sure this would work as is, even if I have changed the names of the submission buttons from the standard "Submit" to something else like "Register"? Will this code still automatically send all form submissions to Google Analytics? Thanks! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment