SOLVED

Losing tracking on tokens

Go to solution
cdeyes89
Level 2

Losing tracking on tokens

Hi all, 

I wonder if anyone has experienced similar and can help. I know there are issues with tracking being lost when using tokens, and we worked around this and had tracking working perfectly using the following (we had about 26 countries in the final code which made it huge as you can imagine):

 

#if(${lead.Segmentation_Country_1006} == "Austria")

<a href"#" target="_blank" style="display: inline-block; background: #2A2A2A; color: #ffffff; font-family: Verdana, Geneva, sans-serif; font-size: 13px; font-weight: normal; line-height: 1.2; margin: 0; text-decoration: none; text-transform: none; padding: 10px 25px 10px 25px; mso-padding-alt: 0px; border-radius: 0px;">JETZT</a>

#else

<a href"#" target="_blank" style="display: inline-block; background: #2A2A2A; color: #ffffff; font-family: Verdana, Geneva, sans-serif; font-size: 13px; font-weight: normal; line-height: 1.2; margin: 0; text-decoration: none; text-transform: none; padding: 10px 25px 10px 25px; mso-padding-alt: 0px; border-radius: 0px;">NOW</a>

#end

 

However, we recently had to send a large email using about 30 tokens, so we tried to cut down on the size of our tokens by consolidating some of the information like below:

 

#set ($c = ${lead.Segmentation_Country_1006})

#set ($link_att = 'target="_blank" style="display: inline-block; background: #2A2A2A; color: #ffffff; font-family: Verdana, Geneva, sans-serif; font-size: 13px; font-weight: normal; line-height: 1.2; margin: 0; text-decoration: none; text-transform: none; padding: 10px 25px 10px 25px; mso-padding-alt: 0px; border-radius: 0px;"')


#if(${lead.Segmentation_Country_1006} == "Austria")

<a href"#" $link_att>JETZT</a>

#else

<a href"#" $link_att>NOW</a>

#end

 

As soon as we have done this, tracking has dropped out again and no email clicks were registered. Please does anyone have any clues on how to cut down on the size of our tokens whilst also still keeping Marketo tracking in place.

 

Thanks in advance for any help,

Charlie

1 ACCEPTED SOLUTION

Accepted Solutions
Jo_Pitts1
Level 10 - Community Advisor

Re: Losing tracking on tokens

@cdeyes89 ,

is your set token in the email before your emit token?

 

Is lead.Segmentation_Country_1006 checked in the list on the RHS?

 

What if you simplify the set token so it has no if statements and just set $emitConfigure to a known value?

 

Cheers

Jo

View solution in original post

6 REPLIES 6
Phillip_Wild
Level 10

Re: Losing tracking on tokens

You are on the right track, but there is some nuance with email scripting. Check out this link: https://developers.marketo.com/email-scripting/

 

In addition to this, you can't spit out links as part of a loop and keep the tracking. So you would create a variable called "link", and assign it in the loop. Then right at the end, you would output the full link with the variable in it.

 

For example:

#set($variable = "default value")

#if(condition)
#set($variable = "value 1")
#elseif(condition)
#set($variable = "value 2")
#else
#set($variable = "default value")
#end

<a href="http://www.${variable}">Link Text</a>

 For example. 

cdeyes89
Level 2

Re: Losing tracking on tokens

Thank you! I'll try setting the links up like this and see how it goes, however the tracking did work when the link was in the first loop and has been working for us for some time, which is odd. It's working out a way to set the link and the wording which differ for each country which has led us to here and it not working any longer.

Jo_Pitts1
Level 10 - Community Advisor

Re: Losing tracking on tokens

@cdeyes89 ,

On top of @Phillip_Wild 's excellent comments, you might want to adopt an approach I use a lot.  I have SET tokens and EMIT tokens.

It does a nice job of separating processing from Display.

in your set token you do all your messy stuff around working out which language gives which outputs and assigning those outputs to variables.

In the emit tokens you simply reference the appropriate variable.  

So, in your example you might have this as your set token (I'll get to a better way of doing some of this stuff in a second.. read on)

 

 

#if($lead.Segmentation_Country_1006 == "Austria")
#set($emitNow='JETZT')
#else
#set($emitNow='NOW')
#end

 

 

 

then in your emit token (let's call it emitNowValue) you'd simply have

 

 

${emitNow}

 

 

and then in your code you'd have

 

 

<a href"#" target="_blank" style="display: inline-block; background: #2A2A2A; color: #ffffff; font-family: Verdana, Geneva, sans-serif; font-size: 13px; font-weight: normal; line-height: 1.2; margin: 0; text-decoration: none; text-transform: none; padding: 10px 25px 10px 25px; mso-padding-alt: 0px; border-radius: 0px;">{{my.emitNowValue}}</a>

 

 

 

for your set tokens, why not set up a map which means you have something like this:

 

 

#set( $allCountryDetails = {
  "Austria" : {
    "valueNow":"JETZT",
    "valueWine": "Wein"
  },
  "England" : {
    "valueNow":"NOW",
    "valueWine": "Wine"
  }
}
#set( $aCountry = $allCountryDetails[$lead.Segmentation_Country_1006]) 
#set( $emitNow = $aCountry.valueNow )
#set( $emitWine = $aCountry.valueWine)

 

 

It gets rid of some crazy hard to navigate, debug, and alter if statement.

 

You'd want to do testing to make sure you'd actually got a valid country match (test to see if aCountry is set) and set the output to defaults if it isn't set.

 

Oh.. and when you are using a marketo lead field (in this instance lead.Segmentation_Country_1006) for setting or comparing, you don't need (or want) the {} around it

 

Cheers

Jo

cdeyes89
Level 2

Re: Losing tracking on tokens

Hi Jo,

 

Thanks for this, it's really helpful and would really reduce the code and the time creating tokens which are used repeatedly across campaigns!

Sadly, I can't get this to work either way round that I try it though

I have this in my set token:

#if($lead.Segmentation_Country_1006 == "Austria")
#set($emitConfigure='KONFIGURIEREN')

#elseif($lead.Segmentation_Country_1006 == "United Kingdom")
#set($emitConfigure='CONFIGURE')

#else
#set($emitConfigure='CONFIGURE')

#end

Then this in my value token:

${emitConfigure}

And my email is literally saying $emitConfigure in the places where I've put the value token 😞

They are both set up as Email Script tokens, is that correct? I'm worried I'm missing something really simple here!

Thanks,

Charlie

Jo_Pitts1
Level 10 - Community Advisor

Re: Losing tracking on tokens

@cdeyes89 ,

is your set token in the email before your emit token?

 

Is lead.Segmentation_Country_1006 checked in the list on the RHS?

 

What if you simplify the set token so it has no if statements and just set $emitConfigure to a known value?

 

Cheers

Jo

cdeyes89
Level 2

Re: Losing tracking on tokens

I had left the set token out of the template, I knew I would have missed something! Thank you so much, this is a great time saver 🙂