Javascript causing error in plugin only

Hello :upside_down_face: ,
I have this script from an external party :

So when it’s placed in HTML header the script correctly executes and I have this :

But if I put the same code inside a “run javascript” workflow I got this:

Or same if I put it on another HTML header page than the first one:

Do someone knows from where the problem could happen?
Cheers :slight_smile:

Do you have the JS Toolbox plugin on the page? If yes, you should share the Toolbox setting.
At first sight, I think you keep the html tag () in the toolbox but you shouldn’T

1 Like

Right <script> tags are HTML elements and are not valid JavaScript.

You would remove those if attempting to execute this code in a Run JavaScript action.

And you wouldn’t execute all of these two scripts in a single Run JavaScript action. The first one you would execute on page load (typically by including it in the page header as your first screenshot does. (Because this script needs to be loaded on the page.) But you could – if for some reason (like you’re on a free plan) you can’t load scripts in the head – execute this in a Run JS action on page load.

Then the second script, you could execute whenever you want to call Canny’s “identify” method (whatever that is).

But if you’re supposed to load this stuff in the page, why are you even bothering to try and execute it via Run JS?

(I see that you note that it seems to work in the head on “one page”, but then does not work when loaded in the head on “some other page”. This isn’t very likely if you’ve in fact included the exact same code. You’ve probably got a typo in the script you think you pasted correctly into “some other page”.)

2 Likes

It’s now working, thank you!

This topic was automatically closed after 70 days. New replies are no longer allowed.