When using GTL in the mailings, I get a broken duplicate of the Mail after the real one

ampscriptcontent-builderemail-templategtlmarketing-cloud

Nice to be here.

I try to create an email on the basis of GTL. I open an AMPScript variable, which contains many key value pairs in a flat JSON format. I do this at the start of the mail like this:

{{.datasource ST type=variable maxRows = 1}}
{{.data}}
   { "target" : "@standardTranslations" }
{{/data}}

After all the content of the mail, which consists of multiple HTML paste content blocks, I end the datasource with:

{{/datasource}}

So far so good. I can access all the keys simply by typing {{ST.keyname}}, which is exactly what I wanted. But now a strange thing happens, when I generate a preview.

I get one working, nice mail, but appended to that a broken, duplicated version, which lacks the GTL personalizations.

The mailing itself is quite heavy on other AMPScript, but I took care, not to put GTL inside of an AMPScript If statement, as I read here on Stackexchange, that this is broken.

When I delete the GTL datasource I get none of the JSON keys resolved, obviously, but also the ugly duplicated mailing vanishes. So it clearly is related to the GTL datasource.

Has anybody experienced this behaviour before or even knows how to fix it?

EDIT:

The JSON looks like this:

[{"ViewEmailOnline":"Nëse ky email nuk shfaqet si duhet, ju lutemi klikoni","ViewEmailClickHere":"këtu."}]

For viewing the values in the mail, I use:

<td width="85%" valign="center" height="24" align="center">
                                        <span style="color: #808890; font-size: 10px; font-family: Arial, sans-serif;">                                           
                                            {{ST.ViewEmailOnline}}
                                            <a href="%%view_email_url%%" alias="VAWP" style="color: #808891; text-decoration: underline;">
                                                <span style="color: #808891;">
                                                    <font color="#808891"> {{ST.ViewEmailClickHere}} </font>
                                                </span>
                                            </a>
                                        </span>
                                    </td>

Hope that helps to examine the problem a bit better. 🙂

Oh, I also tried to use dataobject, but the problem is the same.

EDIT2:

I just did a minimal test and there the problem does not occur. The code looks like this:

<!--%%[
SET @Country = EnrollmentCountry
SET @Language = PreferredLanguage

SET @CountryLanguageKey = CONCAT(@Country,'-',@Language)

SET @standardTranslations = FIELD(ROW(LookupRows("StandardTranslationJSON_fixed","CountryLanguageKey",@CountryLanguageKey), 1),'Translations')

]%%

<div>

{{.datasource ST type=variable maxRows = 100}}
{{.data}}
   { "target" : "@standardTranslations" }
{{/data}}-->
  

<b>GTL says Hello:</b><br>
{{ST.Neutral_greeting_NoGender}} {{FirstName}}<br><br>

</div>

<b>And Goodbye:</b><br>
{{ST.Valediction_Enjoy}}<br><br>

<b>And We look at the imprint:</b><br>
{{ST.imprint-title}}<br><br>

{{/datasource}}

Best Answer

Look into last edit for final/best solution

I found a solution, although it is kind of dumb.

I went into the Code view of the mailing and copied the whole code to a pure HTML mail. And voilà, it worked.

Before the mail was divided in separate HTML content blocks, which, at least in my experience, shouldn't pose a problem. But it did. I guess MC is doing something in the background, when generating the mail with the subscriber data, that breaks my GTL.

I will look further into that problem and now try to copy it once again into separate contentblocks. It just would be much more convenient for our workflow.

For details see the comments under the question. Thank you two so much again.

EDIT: I found a better workaround. I now simply open up the same datasource at the beginning of every content block and close it at the end. Maybe that's even how it is intended to be used, when you have different datasources for different parts of the mailing. For our purpose I simply added both parts as codesnippets and gave the the keys GTLBegin and GTLEnd. A solution I thought of because of your comment @Jonas Lamberty. Thanks for that :-)

Related Topic