Skip to main content

I am using codes by Zapier to separate query parameters from a URL using javascript.

The code works for all but 1 of the query strings (fbclid) and this is happening on all of the zaps i've used this code on.

Whichever parameter is the first in the query string always shows up as a “null” value. 

Not sure why it isn't pulling in this one field even though it is setup like the others.

 

Here is my code:

 

 

I thought I’d post this here for anybody that needs help with doing this same thing. I got the code to work. Here it is:

const url = inputData.url; // http://example.com?
const urlObject = new URL(url);
const id = urlObject.searchParams.get('id')
console.log(id)
// prints
// testconst 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,
};


Thanks so much for sharing the answer with us @cwoolf!