One of my clients is currently testing with Gmail Annotations in their email template. They want to be able to add/remove the Gmail annotation from their email template in a simple manner. They make use of template-based emails, so if I hardcode the annotation code in the head tag in the template it will always be in there.
What I thought I would do is to create some Content Blocks, referencing Ampscript, so that the client could drag a block of Ampscript in their template which would display the Annotation code or hide it. I've done this using the following example:
<!-- This part is part of the email template --> %%[ var @showGmailAnnotation ]%% %%[ if @showGmailAnnotation == "showGmailAnnotation" then ]%% %%=ContentBlockbyName("gmailAnnotationCode")=%% %%[ else ]%% %%[ endif ]%%
The contentblock that's being referenced contains the following:
%%[ var @showGmailAnnotation SET @showGmailAnnotation = "showGmailAnnotation" ]%%
When I ran a test email I did not get any syntax issues. I did however notice that the IF is not being executed, instead it executes the ELSE statement. In hindsight this makes sense, because the var declared above the IF statement does not have the SET value yet.
When I put
%%=ContentBlockbyName("gmailAnnotationCode")=%% in the else block it executed in the following output:
<head> <!-- AMPSCRIPT START --> <table cellpadding="0" cellspacing="0" width="100%" style="min-width: 100%; " class="stylingblock-content-wrapper"><tr><td class="stylingblock-content-wrapper camarker-inner"> <!-- Gmail Annotations code: START --> <div itemscope="" itemtype="http://schema.org/Organization"> <meta itemprop="name" content="Gmail"> <meta itemprop="logo" content=""> </div> <div itemscope="" itemtype="http://schema.org/DiscountOffer"> <meta itemprop="description" content=""> <meta itemprop="discountCode" content=""> <meta itemprop="availabilityStarts" content=""> <meta itemprop="availabilityEnds" content=""> </div> <div itemscope="" itemtype="http://schema.org/PromotionCard"> <meta itemprop="image" content=""> </div> <!-- Gmail Annotations code: END --></td></tr></table> <!-- AMPSCRIPT END -->
I have removed the content from the output, but I was very surprised to see that Marketing cloud wraps the Ampscript output in a table. It seems that the annotation is not working for this reason.
Is there anyone that has an idea how to resolve this issue?