Jump to content

How can I track form submissions in Google Analytics?

Go to solution Solved by foleyatwork,

Recommended Posts

Posted

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.

  • Replies 57
  • Views 56.2k
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Helllo Everyone,

i was very confused to make form with the effects then i concern with the very professional web developer that helps me as more as i need. Try to contact with them if you have any issues in your website

Thanks

  • 3 months later...
  • 2 months later...
Posted

That page returns a 404 error. What was the workaround? I'm trying to track form submission in GTM, too, and it is NOT WORKING.

  • 2 years later...
Posted

I'm looking for an up to date answer to this question as foleyatwork's solution doesn't seem to work with Squarespace 7.1.

 

  • 2 years later...
Posted (edited)

I was able to get this to work by adding 

<script>
gtag('event', 'form submit', {});
 </script>

Into the post form submit HTML block of the UI.

Edited by AndyK
  • 5 months later...
Posted

Seems adding <script> tags in the "post submit HTML" of the form block is not working anymore in 7.1 🤨

...which is quite annoying!

Based on the idea of @foleyatwork I rewrote it to have it working on 7.1

Paste this code in the footer code injection of the whole website:

<script>
    document.addEventListener('DOMContentLoaded', function() {
        console.log('Squarespace ready');

        document.querySelectorAll('.form-block').forEach((formBlock) => {
            const jsonStr = formBlock.querySelector('script[id*=form-context]').textContent;
            const formName = JSON.parse(jsonStr).formName;

            formBlock.onsubmit = function() {                
                // Facebook Lead event example
                fbq("track", "Lead", {content_category: 'form', content_name: formName});
                // Google Lead event example
                gtag('event', 'generate_lead', {event_category:'form', event_label: formName});
            };
        });
        
    }, false);
</script>

 

Hope it helps.

  • 1 month later...
Posted

Hello,

I hope you don't mind me reviving this old thread, as it's exactly what I'm looking for but these solutions aren't working - maybe the JS script in the footer, but ideally I'd like to:

- How can I track the form and button conversions I see in Squarespace analytics in my GA4?

I'd like to see when people subscribe to my email list.

The previous solutions seem to be for older versions of squarespace, google analytics and don't use Tag manager, which I was also trying to work out. Can I tag the event in GA4 Tag manager?

Thanks for your help!


My website is www.jominceramic.com

Create an account or sign in to comment

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

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.