Hi
I’m trying to get to the bottom of a strange problem on my clients website mortgagesforselfemployed.co.uk.
We run Google paid search ads to it and we’re trying to track offline conversions by grabbing Google’s gclid parameter value on the landing page, and passing it through to an embedded typeform at Do You Qualify For A Self-Employed Mortgage? Find Out.
The problem is the custom code our dev has implemented only seems to work on the home page and not on any of our PPC landing pages like: Get A Self Employed Mortgage | Free Quotes - Call Now
The developer is adamant it’s a weird glitch in webflow itself. We’ve contacted webflow support but they say custom code support is outside their remit.
Here’s the amended embedded html on the /dyq page:
<script>
const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('gclid');
console.log(myParam)
var url = "https://leadenquiry.typeform.com/to/MCVudW?typeform-medium=embed-snippet#gclid="+myParam+"&source=";
window.onload = (event) => {
var ifrm = document.createElement("iframe");
ifrm.id = 'typeform-full';
ifrm.setAttribute("src", url);
ifrm.width = "100%";
ifrm.height = "100%";
document.body.appendChild(ifrm);
};
</script>
<script type="text/javascript" src="https://embed.typeform.com/embed.js"></script>
And here’s the global javascript code in the custom code footer section in Project settings:
<script>
// create urlParams variable (constant) from URLSearchParams class using current window
const urlParams = new URLSearchParams(window.location.search);
// set UTM medium, source and campaign variables (constants) based on results of URSearchParams
const utm_medium = urlParams.get('utm_medium')
const utm_source = urlParams.get('utm_source')
const utm_campaign = urlParams.get('utm_campaign')
const gclid = urlParams.get('gclid')
// get the RSVP button element
var rsvpLink = document.getElementById("rsvp");
var rsvpLink1 = document.getElementById("rsvp1");
var ttq3 = document.getElementById("ttq3");
var tooq4 = document.getElementById("tooq4");
var tooq5 = document.getElementById("tooq5");
var tooq6 = document.getElementById("tooq6");
var tooq7 = document.getElementById("tooq7");
var tooq8 = document.getElementById("tooq8");
var tooq9 = document.getElementById("tooq9");
// edit RSVP button element property by appending the URL parameters
rsvpLink.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit rsvp1 button element property by appending the URL parameters
rsvpLink1.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit TTQ3 button element property by appending the URL parameters
ttq3.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit TOOQ4 button element property by appending the URL parameters
tooq4.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit TOOQ5 button element property by appending the URL parameters
tooq5.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit TOOQ6 button element property by appending the URL parameters
tooq6.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit TOOQ7 button element property by appending the URL parameters
tooq7.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit TOOQ8 button element property by appending the URL parameters
tooq8.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// edit TOOQ9 button element property by appending the URL parameters
tooq9.href += "/?medium=" + utm_medium + "&source=" + utm_source+ "&campaign=" + utm_campaign+ "&gclid=" + gclid;
// log final RSVP button link to console
console.log(rsvpLink.href);
console.log(tooq9.href);
</script>
If anyone can help we’d be very grateful. Video and share link below.
Share link:
Here is my site Read-Only: LINK
(how to share your site Read-Only link)