4

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}}
9
  • can you share a sample of your JSON? And/or an example version of your GTL used? Commented Dec 9, 2021 at 13:56
  • 1
    Yes, of course. I just added an edit. Commented Dec 9, 2021 at 14:44
  • This is not a way to solve the root cause, but what if you wrap all the code after your data source in an IF statement forcing it to only display if value {{#=if ViewEmailOnline}} content {{/if}}. and just select a field that will always have a value in your JSON. This way it may not solve the problem, but it will hide the symptom Commented Dec 9, 2021 at 14:53
  • 1
    If a minimalist example works, then this sounds like there might be some sort of syntax error or similar somewhere else in your code that is causing unexpected behavior. Might be worth just taking it apart section by section until you find the place that when removed gets rid of the duplicated content. This is then where your issue is occuring. Commented Dec 9, 2021 at 15:18
  • 1
    Hi guys, I found a solution, albeit it is a bit dumb. In my original mail the content was split up over multiple html content blocks. I now went to the codeview, copied the whole code and pasted it into a pure HTML Email. I can't say why, but it works. I guess MC is doing some stuff to the contentblocks, that's not visible elsewhere?! I will look further into it and keep you posted. Thank you so much for putting your brain into that, helped me to look at it from another perspective. I cleared the text version as a test btw and unfortunately it changed nothing. Commented Dec 9, 2021 at 15:26

1 Answer 1

2

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 :-)

3
  • 1
    Maybe, to keep some sort of workflow that is not reliant on one monolithic piece of email (you'll have to decide if there is something in this for you...) you can try to store separate Code Snippets, which don't come with the clutter that plagues Content blocks that seems to trigger your problem. You could at least divide your content into %%=ContentBlockByKey()=%% parts (with human readable keys ...) that can be edited separately. Just putting it out there, maybe it's not helping this time, but Code Snippets are your friend sometimes :) Commented Dec 10, 2021 at 8:00
  • See latest edit! Wonderful you helped me a long way along my thought process. I did not know that you can give custom keys. That is genius. Used it nor for a ton of other stuff too. Thanks so much. Commented Dec 13, 2021 at 11:54
  • nice, good to hear! Commented Dec 13, 2021 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .