I used the code below in my zapier workflow to --- capture UTM info when a lead takes action on our website, fills out a form, then gets routed into pardot/salesforce.
Steps:
1: webhook
- code for UTMs
- prospect routing through pardot/salesforce
I used for URL: http://site.com?utm_source=source&utm_campaign=campaign&utm_medium=medium&utm_term=term&utm_content=content
and the code I used:
const url = inputData.url; //
http://example.com
?
const urlObject = new URL(url);
const id = urlObject.searchParams.get('id')
console.log(id)
// prints
const utm_term = urlObject.searchParams.get('utm_term');
const fbclid = urlObject.searchParams.get('fbclid');
const gclid = urlObject.searchParams.get('gclid');
const gacid = urlObject.searchParams.get('gacid');
const utm_campaign = urlObject.searchParams.get('utm_campaign');
const utm_content = urlObject.searchParams.get('utm_content');
const utm_medium = urlObject.searchParams.get('utm_medium');
const utm_source = urlObject.searchParams.get('utm_source');
output = {
"utm_term":utm_term,
"gclid":gclid,
"fbclid":fbclid,
"gacid":gacid,
"utm_source":utm_source,
"utm_campaign":utm_campaign,
"utm_medium":utm_medium,
"utm_content":utm_content,
};