EPN Smart Links

Seems when I attempt to add Smart Links that turn eBay links into rover .ebay. com affiliate links, it’s stripping out the script code with the campaign id that is essential to building the link.

<script>window._epn = {campaign:XXXXXXXXXX};</script>
<script src="https://epnt.ebay.com/static/epn-smart-tools.js"></script>

I add this to the theme’s header but it seems after saving and viewing the page source, the first line of the script is completely wiped away:

<script>window._epn = {campaign:XXXXXXXXXX};</script>

If I comment the tag out with it shows up in the source code.

Am I missing something? This code works fine on Wordpress and other sites. What would cause this to get stripped which I believe is the cause in ebay links not turning into affiliate rover ebay com links.

Thanks for any insight or suggestions.

1 Like

Are you adding those snippets to the theme </head> area? Also, did you add this script URL to the CSP site setting ?

1 Like

Yes I’ve added to the /head setting.

Right now this is on a test instance so all CSP is disabled.

That line should be extracted into a theme file, since inline Javascript is not allowed in recent versions of Discourse (for CSP). Did you check all theme JavaScript files too?

1 Like

That might be it then if I need to add that line to the theme. I take it I’ll have to add outside of the theme customization administration into the themed files? Where would I do that exactly, within the container itself on the flat files or code? Right now I’m just testing with the default Light theme. Thanks.

After reading your reply again, this doesn’t make sense if I’ve disabled CSP entirely. So by disabling CSP and it’s still blocking inline scripts, that tells me it’s not entirely disabling CSP. Or am I missing something?

We put all JS into files, because makes no sense for us to not do it, since CSP is a default in all sites out of the box.

Okay, that makes sense but doesn’t make sense if one disables CSP but yet it’s still enabled from what you’ve told me.

So do I need to create a new public/javascripts file with this bit of the code and have it load from there as something like:

<script src="epn_links.js"></script>

You’ll have to excuse my newbiness. I’m not a developer, just trying to setup a Discourse site that enables EPN links so any ebay links turn into affiliated links.