Set the javascript in <head> and additional script to only run on certain landing url utm parameter

ryanccsb
New Member
6 0 0

Hi all,

I'm using javascript to capture conversion event. The script is in <head> and Additional Script at checkout page.

Problem with this script is that it capture conversion orders for each and single order that went through by the advertiser, rather than only capture conversion orders for traffic from certain publisher

Is there a way to only enable the javascript to only run if the redirect comes from certain publisher ? (eg. from publisher A - landing URL = www.domain.org/?utm_source=publisherA)

hence if user directly land on www.domain.org - will not trigger the javascript as they complete the checkout


ryanccsb_1-1613646798572.png

 

ryanccsb_0-1613646723605.png

 



0 Likes
Jayvin
Shopify Partner
217 34 56

Hi Ryan,

Yes it's possible sample of javascript can be something like this:

const urlParams = new URLSearchParams(window.location.search);
const utm_source_value = urlParams.get('utm_source_value');

if(utm_source_value){
 // wrap the codes here..
}
0 Likes