Have you looked into using Google Tag Manager instead of (well really it is 'in conjunction with, I guess) Google Analytics? It's more elegant and means that different ad / page impression services etc can be added and removed without you editting the site itself once deployed.
Handy if you pay someone to do this for you, or even if you do it yourself and want to make sure you don't accidentally fuck something up making a minor analytics change. Can also easily say what service you want loaded on what page etc. if you start doing deeeeeeep analysis.
If you've never used it before, get on Google Tag Manager. Much easier way of controlling your analytics and events, etc. Sounds like that's what they want.
There's loads of tutorials around. Takes a bit of getting used to but will make sense in the long run (and make your life miles easier).
You can easily read the referrer and only trigger the JS, but that's if you can get and want to maintain a full list of referring domains. Can you find a full list of domains that might be referring to my site based on Google Adwords? Can you get notifications when a domain is added to that?
A better solution than referrer is to add a query string parameter to linked urls with the source, like ?src=adwords. That way you know which ad placement it came from and you can trigger it.
But that still doesn't let you get around remarketing pixels. Remarketing pixels are fired on every visit, so that advertisers can push ads to people who've visited a site to get them to come back. If you turn off adblock, you'll start to notice ads very much targeted based on sites you've visited, or even individual products. And you have to fire those pixels on every visit or you won't be able to remarket to folks who bail.
Edit: Also, if you don't want to maintain this code yourself, you can use a tag management solution (like Google's) to add the tags like a CMS.