How can I dynamically call an image using a token?

Level 3

How can I dynamically call an image using a token?

Hi,

 

I am currently working on an email where the smart campaign is based on source=web api and flow is = send email.

 

Now, In this email we need to pick different profile info( profile or avatar image, level and name )from a clan game.

 

However, I am struck because I do not understand how do we pick dynamic profile images with the help of my.tokens.

 

We want the email to capture the avatar image with name and level like you can see below but I am not sure how to do that.

I was thinking to use multiple tokens like {{my.Avatarpic}}{{my.level:default=X}}{{my.name:default=Ashlee}}but the backend team(api) i am working on is not sure if this will work.

 

The API team said: Please tell how to run this email; with value provided for tokenswhich VALUE should I provide for avatar so it will be dynamically render image of new member.I am very confused here as I have not come across this kind of scenario before.

 

Capture.PNG

 

 

 

10 REPLIES 10
Level 6

Re: How can I dynamically call an image using a token?

Fun problem!

 

You don't want to use program-level {{my.tokens}} here since a person's clan is set at a person level. Unless you have one email per clan or something - but it doesn't sound like that's your scenario. 

 

So if I a person can only have one clan, level, and name at a time then you want this to be written into a person's lead profile. You can do this via API 200 at a time using syncLeads (https://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Leads...) or via a csv/tsv upload in the Bulk API (https://developers.marketo.com/rest-api/bulk-import/). Either way, you will end up with something like this on each applicable person in Marketo:

 

First Name: Phil

Last Name: Wild

Clan: Example Clan

Level: Level 10

Img: www.example.com/1.jpg

 

If image is different for each user, put it on the person's record as per above. But if the image is based on clan (and therefore you have, say, only 10 different images) then I would use an inherited email script token from a top level program instead. Something like this:

#if( $clan = "clan1")

#set($image = "www.imagelocation1.com")

#elseif($clan = "clan2")

#set($image = "www.imagelocation2.com")

....

and so on. Better ways to do this but you get the idea. 

 

If you then set images at an inherited program level you can use those tokens everywhere, in every email, and if the image location changes you change it in one place. Not in every lead profile. 

--------

 

So overall you can tell your API team that they can either:

 

1) Do a bulk update of all relevant profiles in Marketo before a send, so everyone has the right info; or, ideally,

2) When someone is created, or their clan / details change, then update them in Marketo via the API. That way whenever you send an email their information will always be correct.

 

This is the best solution I can thing of, assuming you don't have an existing Salesforce / MS Dynamics sync that would do all of this automatically. Hope this helps!

Level 10 - Community Moderator

Re: How can I dynamically call an image using a token?

Should be 

 

#if( $clan.equals("clan1") )

 

though.

 

= won't work, == is buggy, .equals is what you want.

Level 3

Re: How can I dynamically call an image using a token?

Thanks for your reply but I am still not clear as to what needs to be done from my end(in marketo)

 

We have some fixed profiles/avatars (say 30-40) for the game so that whenever any new member joins he needs to pick one from them.

My question is how do I define the tokens for the same in the email? Shall I upload all profiles in design studio?

 

We need to populate the profile picture, country, level for each new user who joins which definitely should be dynamic and that's why I thought of using {{my.tokens}}. But how do we capture images through these tokens? Do I need to use multiple tokens for all the criteria that we need?

 

Also, what should be the data structure/format for these dynamic tokens? will it be json?

Level 10 - Community Moderator

Re: How can I dynamically call an image using a token?

It's up to you how to do the specific implementation.

 

You have to populate at least one field on the lead. Probably a single Textarea field with a JSON object is best.

 

Phillip's suggestion (and it's a good one) is that because there are so few avatars (relative to number of people), you could store an alias for the avatar image in the JSON field, rather than the full URL, which is more of a proper "denormalized" config. Then the full URLs are stored in a separate Velocity {{my.token}}, which becomes a generic kind of lookup table. But you don't have to do that, you can persist the whole URL right in the lead field.

Level 3

Re: How can I dynamically call an image using a token?

Thanks for your reply but what you mentioned in the last post is mainly technical and needs to be done from API point of view.

 

For Marketo email do you suggest me using a lead token for example {{lead.s_clan_profileinfo}} with a default value of one of the profile URLs once I upload all of the profiles in design studio?

 

Do I need to use multiple tokens or one should be enough to capture profile pic, country and level.

Level 10 - Community Moderator

Re: How can I dynamically call an image using a token?

Thanks for your reply but what you mentioned in the last post is mainly technical and needs to be done from API point of view.


Well, your question is inherently technical, so I don't understand the objection?

 


For Marketo email do you suggest me using a lead token for example {{lead.s_clan_profileinfo}} with a default value of one of the profile URLs once I upload all of the profiles in design studio?


If that field contains everything you need (a full HTML fragment) sure.


That's not the way I would do it, as noted I would use an actual JSON data structure in the lead field, and then assemble the HTML using a Velocity {{my.token}}.

 

Level 3

Re: How can I dynamically call an image using a token?

Thanks for your reply. 

When you mention, "I would use an actual JSON data structure in the lead field, and then assemble the HTML using a Velocity {{my.token}}"

 

I am not aware of this process but if there is a guidance that you can share I can try it. Is this something that we need to update in the HTML of the email?

 

Incase, if I am not able to do this; please suggest that in this case whether it makes sense to use lead or my.tokens?

Level 10 - Community Moderator

Re: How can I dynamically call an image using a token?


When you mention, "I would use an actual JSON data structure in the lead field, and then assemble the HTML using a Velocity {{my.token}}"

 

I am not aware of this process but if there is a guidance that you can share I can try it. Is this something that we need to update in the HTML of the email?


I'm talking about storing all the profile information in a JSON structure in a single Lead field. You'd then use a {{my.token}} to parse it. It doesn't sound like you're at the technical level to do that, however.

 


Incase, if I am not able to do this; please suggest that in this case whether it makes sense to use lead or my.tokens?


As noted earlier, the only kind of {{my.token}} that can output different content for different leads is a Velocity {{my.token}} (and, to a small degree, a Calendar token).

 

If you aren't using a Velocity {{my.token}} then you will store the different pieces of data in different lead fields, then include multiple {{lead.tokens}}.  Or you could write one big HTML fragment to a single lead field and use one {{lead.token}} - but only if all the data is meant to appear together, exactly as formatted.

 


@Lopa1408 wrote:

Thanks for your reply. 

When you mention, "I would use an actual JSON data structure in the lead field, and then assemble the HTML using a Velocity {{my.token}}"

 

I am not aware of this process but if there is a guidance that you can share I can try it. Is this something that we need to update in the HTML of the email?

 

Incase, if I am not able to do this; please suggest that in this case whether it makes sense to use lead or my.tokens?


 

Level 3

Re: How can I dynamically call an image using a token?

I feel this will be the best option for me "you will store the different pieces of data in different lead fields, then include multiple {{lead.tokens}}.  

 

Do you want me to add custom fields under admin or how should I store the data in different lead fields?

 

The API team wants me "to get them the email with url to profile working from token" how do I give them the URLs. What is the way to store the URL of different profiles in marketo and use them as tokens?