SOLVED

Has anyone been successful in adding Gmail annotation to a Marketo email template?

Go to solution
lillyfalcon
Level 3

Has anyone been successful in adding Gmail annotation to a Marketo email template?

Hi 

 

I'm new to the Marketo Community and not sure if this the best board to ask questions about Marketo email templates. 

 

We are a adding a new modular email template to Marketo with Gmail Annotations but getting this error message: 

"Marketo does not allow javascript or script tags in email HTML. Please refresh your browser."

 

Has anyone had a similar problem? Thank you 🙂

Lilly Falcon
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

Yes, you can use Gmail Annotations in Marketo emails.

 

The problem is you're choosing the JSON-LD format for your annotations (which isn‘t the only format) and Marketo mistakenly thinks JSON-LD, which uses a <script> tag to create an HTML data block, is instead an executable script. In reality, it’s not executable and poses no security concern.

 

You can skip this check by adding the <script> tag to the <head> of the template and putting an Email Script {{my.token}} inside it.  The {{my.token}} contains the JSON.

View solution in original post

16 REPLIES 16
Floyd_Alvares2
Level 8

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

Hi @lillyfalcon 

I believe Marketo does not allow for <scripts> to be included into the HTML templates. This is more form a security risk point of view.

I am assuming your Gmail annotation has scripts - which is why you are receiving this error.

Thanks

Floyd

lillyfalcon
Level 3

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

Thank you so much for your help, Floyd! Yes it does 🙂 

Lilly Falcon
SanfordWhiteman
Level 10 - Community Moderator

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

Yes, you can use Gmail Annotations in Marketo emails.

 

The problem is you're choosing the JSON-LD format for your annotations (which isn‘t the only format) and Marketo mistakenly thinks JSON-LD, which uses a <script> tag to create an HTML data block, is instead an executable script. In reality, it’s not executable and poses no security concern.

 

You can skip this check by adding the <script> tag to the <head> of the template and putting an Email Script {{my.token}} inside it.  The {{my.token}} contains the JSON.

lillyfalcon
Level 3

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

Amazing., thank you! I'll add the <script type="application/ld+json"> to a snippet inside the head tag and report back if have any issues.

 

I should have thought of this, especially as I'll need to edit some of the content periodically but wasn't sure if possible. I haven't had much luck with tokens, they are less flexible and a bit buggy (cannot determine which assets attached to).

 

Do you know if there are any best practices for coding HTML snippets? I have been using a bit of trial and error as cannot find any Marketo documentation or discussion about this. 

 

Thanks again! Your answers are always so helpful 🙂 

Lilly Falcon
SanfordWhiteman
Level 10 - Community Moderator

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?


I should have thought of this, especially as I'll need to edit some of the content periodically but wasn't sure if possible. I haven't had much luck with tokens, they are less flexible and a bit buggy (cannot determine which assets attached to).

Hmm, I wouldn’t say they’re buggy, tokens are kind of the lifeblood of a manageable Marketo instance!

 

It’s true that determining ‘Used By‘ isn’t possible, but you have to consider that in token-centric instances — which most complex Marketo instances are — you could be talking about 10,000+ assets referencing a {{my.token}}. So it wouldn’t be useful to see a list of the assets, since it would overflow any reasonable display.

 


Do you know if there are any best practices for coding HTML snippets? I have been using a bit of trial and error as cannot find any Marketo documentation or discussion about this. 

Not any practices that are different from coding HTML for email in general.

dbassett
Level 2

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

Hi @SanfordWhiteman,

 

I am hoping you can help me troubleshoot. I tried putting the entire annotation script inside of a velocity email script token, and then inserting that token - {{my.annotation}} - into the <head> element of my email template. When I save it, Marketo inserts a <body> tag in front of the token. This might be why the Gmail image does not show up when I send the test email to a promotabtesting@gmail.com account I created. To be clear, the email shows up in the promo tab, but without the "annotations" image beneath it, and without the logo image to the left of the message.

 

I'm thinking you cannot put a token in the <head> element of an email without Marketo inserting a <body> tag and essentially removing it from the <head>? Can you please instruct me on how to get around this? I tried commenting out the token in order to avoid an unnecessary <body> tag from being added by Marketo, but I suspect that causes the token to not populate. Furthermore, I did try the microdata suggestion from another user in the <body> of the email,  but that also failed to generate the image when sending the test email.

 

Any ideas? Thanks!

 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?


I'm thinking you cannot put a token in the <head> element of an email without Marketo inserting a <body> tag and essentially removing it from the <head>?

I can’t reproduce that behavior. JSON+LD in the head is fine for me.

dbassett
Level 2

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

So that I understand more clearly, are you adding JSON+LD to the <head> in the following way? 

 

<head>
<script type="application/ld+json">
{{my.token}}
</script>
</head>

 

or putting <script type="application/ld+json"> as part of the token?

 

<head>
{{my.token}} /* includes the <script type="application/ld+json"> */
</head>

 

In the case where I have the <script type="application/ld+json"> I get the Marketo javascript error, and when I have it as part of the token and put the token in the head, I get Marketo moving the token into the <body> and removing it from the <head>. 

 

It ends up looking like this after saving:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head></head>
<body>
{{my.annotation}}
<p>Email Body</p>
<p>Line 2</p>
</body>
</html>

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Has anyone been successful in adding Gmail annotation to a Marketo email template?

I have this part in the template:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <script type="application/ld+json">
   {{my.Gmail Annotation}}
    </script>
  </head>

then the rest is in the Velocity token.

 

Marketo doesn’t add any extra tags or have any errors w/this setup.