The Background
We recently had a client switch marketing automation platforms to Pardot (a solution by Salesforce) due to its B2B specialty. As the keepers of the Google Analytics, we needed to ensure we had a seamless transition tracking the different forms, demos, and gated content across the site.
For SEO purposes, we recommended that the Pardot forms be housed within an iFrame on our client’s domain, rather than a separate Pardot landing page ( this allows us to retain the page equity within our site). For scalability, we track form submissions as Google Analytics Events.
The Question
How do we track Pardot form submissions as Google Analytics Events?
We love when analytics pull dynamically (hello, dataLayer) and we can take things off our client’s plate by handling them ourselves within Google Tag Manager, so we thought:
Can We Do This All with Google Tag Manager?
Can we pull in the Event Category, Action, and Label dynamically from the page within the dataLayer by adding the Google Tag Manager container within each Pardot form, and configuring the rest with Google Tag Manager magic?
Did it Work?
Ah! The dreaded iFrame! Since the forms are embedded in an iFrame on our client’s site, the container wasn’t able to successfully talk to the Pardot form and extract information from the landing page.
So we decided to simplify our approach with a couple basic steps.
The Solution
Step #1: Identify Your Pardot Form Completion Action Type
Same Page
The Same Page type means everything happens within your Pardot form and keeps users on the same URL after submitting the form. It may or may not present the user with Thank You Content like in the image below, and DOES NOT have the “Redirect the prospect instead of showing the form’s Thank You Content” box checked.
For the Same Page Completion Action, no additional code is needed.
External Page Redirect
The External Page Redirect type means your page redirects to an external page, e.g. after a form submission your Pardot form redirects the user to gated content housed on an external domain.
With External Page Redirect Actions, we need to maintain our ability to fire event tracking via the Thank You Code Completion Actions field; the event needs to fire before the redirect, so we need to delay the redirect for a few seconds.
Here’s an example of a script you can use to delay that redirect:
See the Pen Pardot Event Tracking Script 1 by UpBuild (@upbuild) on CodePen.
Step #2: Add in Google Analytics Event Tracking Script
The universal piece of the puzzle here will be to add our event tracking within Pardot with Event Category, Event Action, and Event Label fields filled out for the specific form:
Navigate to Forms > Completion Actions > Thank You Code in Pardot.
Paste the following script into the “Thank You Code” field and update the category, action, and label fields to match the specific form.
Update: For the secure version of the Pardot tracking, you also need to include the site’s unique Google Analytics Tracking Snippet:
See the Pen Pardot Event Tracking Script 2 by UpBuild (@upbuild) on CodePen.
Example:
Rinse and Repeat
These simple steps have become a part of the process for whenever a new form is added to the site. With a few extra clicks and a copy + paste we have consistent event tracking across our client’s site’s forms.