0

I am trying to find the best method in a Marketing Cloud email to continuously pull data from a JSON file that updates every 5 seconds so that it is "Live" Data within the email.

Currently I am using Ampscript and SSJS to pull in the data upon send to the individual recipient. This also allows the VAWP link to show the current data upon refresh for a limited time.

EDIT: We would like it to continuously update and show after the email send, similar to a countdown timer, but it is counting up based on the data in the JSON.

JSON Data Example

{
   "Odometers": [
       {
          "LevelId": 28,
          "Value": 57102.82
       },
       {
          "LevelId": 914,
          "Value": 50863.31
       }
   ]
}

Code Snippet Example

%%[
var @response,@value,@progressive,@locale

set @response = HTTPGET("https://URL/filename.json",false,0,@CallStatus)
]%%

<script runat="server" language="javascript">
Platform.Load("Core","1");
  
//Get the @response variable from AMPscript
var json = Variable.GetValue("@response");

//Extract the nested JSON objects
var _JsonObject = eval('(' + json + ')');
  
//Set the @value variable to be accessible in AMPscript. If there are multiple data rows, start the row count at 0 for the first row to get a match level ID.
Variable.SetValue("@value",_JsonObject.Odometers[0].Value);

//Updates upon send, and also when VAWP link is clicked, or on refresh of the VAWP link.
</script>

%%[
set @locale = "en-US"
set @progressive  = FormatCurrency(@value, @locale)
]%%

The current amount is %%=v(@progressive)=%%
<br><br>
 @response: %%=v(@response)=%%
2
  • Do you want it to update the email content based on the JSON, even after the email is sent? – Lukas Lunow Oct 14 '20 at 19:36
  • Yes. That is a good clarification. I will make an edit to my question. We would like it to continuously update and show after the email send, similar to a countdown timer, but it is counting up based on the data in the JSON. – Tiffiny W Oct 14 '20 at 20:10
3

It is not technically possible to replace/update text content in an email after it has been sent. The examples shown e.g. here: How to refer Javascript cloud page in my email in content builder? and or here: Real time dynamic emails all rely on images, that are fetched at open. But the referencing URLs remain the same once the email has been generated and sent.

All of the technologies you mention: SSJS, GTL, Ampscript are processed at sendtime, and content from any external URLs will not be refreshed afterwards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.