Hi,
I know what is causing the issue and I can help you rectify it, the user who created the script didn't know how to differentiate between Google Ads and Google Organic traffic so the issue. We can use the presence of gclid to identify Google PPC traffic.., I'm assuming you want to track this info in Google Analytics, then why aren't you using UTM parameters instead of writing a script?
Please message me and we could discuss this further.
Best,
Sai Madhan