Reputation: 13
Squarespace Index pages have a main page and a sub page. It looks like the following:
Squarespace cannot pass UTM parameters through a form, so I'm using a script in Google Tag Manager to pass the UTM parameters to Squarespace's SQF format:
Reference: How to track UTM data in Squarespace form submissions
Within the forms I have hidden fields SQF_CAMPAIGN, SQF_TERM, etc. that collects the data the script parses and the URL parameters are collected when the form is submitted.
I have a form block on each page of the index. It looks like this:
From the the website visitors perspective it is one page and one URL. From Squarespace's design architecture it is considered two pages.
What I'm trying to solve for is getting the URL Parameters to submit with Form 2. Currently Form 1 functions without issue. All parameters are sent. Prior to release I started testing the other form and realized the parameters are not being collected. I tested this on multiple pages.
I suspect that PAGE 2, FORM 2 is not pulling in the data because it is in reality a separate URL. I did test with just using a URL with SQF parameters only and I was able to pull in data on PAGE 2, FORM 2. Although, I need the UTM parameters for further tracking, so using just SQF is not solving my issue. I could be mistaken.
Ideally a user clicks on a Google paid search campaign, therefore all the UTM parameters will be tagged on the landing page URL, and when they submit any form on the pages the parameters will be collected.
Can anyone provide a solution to this?
Upvotes: 1
Views: 1486
Reputation: 3687
The issue is caused by the fact that the snippet of code you are using was written to handle only a single form. That is, it assumes there's only one form on a given page. It does not have to do with index page architecture in Squarepace.
The issue can be fixed by adding a loop within the code, like this:
var i = formFields.length;
while (i--) {
if (formFields[i]) {
formFields[i].value = params[param];
}
}
The original answer has been updated with this snippet of code.
Upvotes: 0