Best answer

Javascript Error - Can't Separate UTM Parameters from Query String using Code by Zapier

  • 31 March 2020
  • 2 replies

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:




Best answer by cwoolf 31 March 2020, 20:50

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

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; //
const urlObject = new URL(url);
const id = urlObject.searchParams.get('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,

Userlevel 7
Badge +12

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