SOLVED

Re: Can you add script to a Marketo token?

Go to solution
Liz_Nguyen1
Level 3

Can you add script to a Marketo token?

We have many landing pages where we have some custom script added in the LP: Custom HTML Head Section. 

Since we need to update these pages and the script would only be on selected LPs, not all,  looking at a way to do it via tokens. 

Can script be added in a Marketo token like a text token then the token be added to the Custom HTML Head section of the LP?

Are there limitations on lines of code in a Marketo token and what is the correct way to add it?

 

Thanks, 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Can you add script to a Marketo token?

I don't believe it's necessary to add JavaScript directly to the tokens as a matter of fact for its centralized management. You can simply load the JavaScript file in the Design Studio under 'Images and Files' and then just load the external JS file via the file's Design Studio URL on your landing page (you can place this in the 'Custom HTML Head' section). You can even add this at the template level if all the LPs created from it would need this. This way you'd not have to add the JS file to each LP page individually.

 

<script src="https://example.com/your-js-file.js"></script>

 

This is how users typically manage JavaScript that is used in multiple places, rather than adding it separately in the 'Custom HTML Head' section and then having to update it in each place individually.

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Can you add script to a Marketo token?

Like Darshil says, the preferred way to insert JS is to

 

(a) use external JS files hosted in Design Studio

(b) embed them on the template, using a mktoBoolean to toggle them on/off per page

 

Using Custom Head HTML for per-page code, or putting code in a {{my.token}} that’s used on the page, simply doesn’t scale. It’s not that you’d run out of space in a {{my.token}}, it’s just a terrible way to store/serve code. Using Design Studio allows JS to be both cached by the browser and shared across pages.

View solution in original post

4 REPLIES 4
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Can you add script to a Marketo token?

I don't believe it's necessary to add JavaScript directly to the tokens as a matter of fact for its centralized management. You can simply load the JavaScript file in the Design Studio under 'Images and Files' and then just load the external JS file via the file's Design Studio URL on your landing page (you can place this in the 'Custom HTML Head' section). You can even add this at the template level if all the LPs created from it would need this. This way you'd not have to add the JS file to each LP page individually.

 

<script src="https://example.com/your-js-file.js"></script>

 

This is how users typically manage JavaScript that is used in multiple places, rather than adding it separately in the 'Custom HTML Head' section and then having to update it in each place individually.

Liz_Nguyen1
Level 3

Re: Can you add script to a Marketo token?

Hi Darshil - we attempted to save our JS file in Design Studio as you suggested and used the following script src format to serve it on individual LPs to test it out. When we added it to the LP Custom HTML Head section, it didn't seem to fire. But when we copied the JS as is directly into the section, it worked. Any advice on what we could be doing wrong, or if the order 

<script src="https://example.com/your-js-file.js"></script>

 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Can you add script to a Marketo token?

Did you verify this by checking the F12 Developer console? I'd usually check the Network tab to verify whether the request to the JS file was successful or not.

Darshil_Shah1_0-1697731899485.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Can you add script to a Marketo token?

Like Darshil says, the preferred way to insert JS is to

 

(a) use external JS files hosted in Design Studio

(b) embed them on the template, using a mktoBoolean to toggle them on/off per page

 

Using Custom Head HTML for per-page code, or putting code in a {{my.token}} that’s used on the page, simply doesn’t scale. It’s not that you’d run out of space in a {{my.token}}, it’s just a terrible way to store/serve code. Using Design Studio allows JS to be both cached by the browser and shared across pages.