Google Analytics and Formstack for Salesforce

Did you know?

Formstack offers in-house Professional Services & Packaged Solutions for those who want to customize their Forms but do not have the time or internal resources to get these projects completed.  For more information on pricing and to book your consultation, please click here!

If you don’t already have a Google Analytics account, go ahead and create one here :

Google analytics has multiple ways of tracking engagement and activity on your website and webforms. In this article we will focus mainly on the Google Tag Manager. In order to use Google Tag Manager you would need to create a Google Tag Manager Account:


This guide is meant to provide ideas on how to implement Google Analytics and the code and forms mentioned in this article are not actively maintained by our team.  Support for this process is limited.

In this article you will learn how to track 3 things

  • Page Views
  • Form Submissions
  • Specific field values

These 3 options will make use of Tags, Triggers, and Variables and give you a brief idea of how they can be used to report on your form.

We will use this sample Formstack form:

Installing Google Tag Manager in your form

  • Go to your Google Tag Manager Admin tab
  • Under the “Container” Settings click “Install Google Tag Manager”
  • You should see something similar to the screenshot below
  • Only copy the highlighted portion and paste it in your Form Settings -> Javascript Code Area


Page Views

  • Go to Tags in google tag manager and create new tag
  • Select “Page View” as the track type. Select tag configuration as “Google Analytics: Universal Analytics”
  • Check “Enable overriding settings in this tag
  • Add in your Google Analytics Tracking ID. See this article to find your Tracking ID:
  • Publish your changes

Form Submission


  • Go to Triggers in google tag manager and create new trigger
  • Select the “Form Submission” trigger type.
  • You would then have to create a Tag to have this tracked in Google Analytics. So go to Tags -> Set the track type as Event and then add in a Category (eg. Form Submit) and Action (eg. Contact Us Form) that can seen in Google analytics
  • Add the trigger you created to that tag
  • Publish your changes
  • In order for Google Analytics form submission trigger to recognize the Formstack form submit Action you would need to add the following Javascript code to your Form Settings -> Javascript Code Area.
function FF_OnAfterSave()

document.getElementById("form1").setAttribute("action", "");




What this code does: The Google Analytics form submission trigger listens for the form submit action to be called on a web form. With Formstack forms we do not use the standard form submit action, instead we have some custom functions that will encrypt, format and submit your data to Salesforce. The above code will replicate a standard form submit action to be executed alongside Formstack’s submission.


Value in a form field

This works great if you want to build reports based on specific answers someone is providing like a lead source. In the above form example we have a “How did you hear about us field?” and want to send the response to that over to Google Analytics. 

  • For this to work we would first need to be tracking the Form submission data. So make sure your changes from the Form Submission section above have have been published
  • You would also need to activate Preview mode for Google Tag manager to find the right variable.
  • Follow the instructions in this video:


    When Formstack makes a submission it actually clears the Data Layer variables so you might not be able to see those values in your browser console, but they will get tracked using Google Analytics once you have the Tag set up.

  • You can choose to create a separate tag for this event or use the same one that we created for the Form Submission tracking like they did in the above video
  • Publish your changes
Was this article helpful?
1 out of 1 found this helpful



Article is closed for comments.