SOLVED

Re: Set Value of Local Token via JavaScript

Go to solution
Anonymous
Not applicable

Set Value of {{my.token}} via JavaScript

Hello,

is it possible to set and overwrite the value of a local token via JavaScript? If yes, how do I access the token in the JS snippet?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Value of {{my.token}} via JavaScript

If a certain amount is reached, an alert should be sent to an email address, so that the respective smart campaigns of that program could be deactivated on time. This could be easily achieved if I just create a new custom field, but since this value is rather relevant for the program than for the lead itself, I settled for the my.token.

There are a couple of ways to accomplish this.

  • The way that uses only native Marketo functions (albeit in a hacky-slash-elegant way): create a Resource Contact (RC). This is a Marketo person record that represents the Program itself (it's like when Microsoft Exchange or another collabo platform lists conference rooms and copy machines as resources).  Whenever someone is added to the Program, send out a webhook to the /save endpoint on your instance. This will do a form post on behalf of the RC. A trigger campaign hears those form posts and increments a score field on the RC's record. When score is exceeded, alert, turn off SC, profit, etc.!
  • The way that uses an external service to maintain the counter.  FlowBoost* has a feature designed for this called FBCounter. FBCounter is not only used to add, remove, and count event registrants, it also has the advantage (vs. the RC method) of being readable from the client side, so you can check the current count and redirect the page to an "event full" page automatically (even if the SC is still running).

You might want to try the RC method first and see how it works out for you. I'm rather a fan of it really (AFAIK, I came up with the concept!).

* I'm the tech lead of the FlowBoost platform.

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Value of Local Token via JavaScript

Can you rephrase your question?

"local token" typically means a {{my.token}} in the current Program. And writing local tokens can't be done from the browser side at all (this would mean leads could overwrite data shared by everyone in the program -- a definite no-no!).

Certainly you could display data from the browser in place of a {{my.token}} that is embedded in the page. But that wouldn't be called "setting" or "overwriting."

What is the exact effect you want to achieve?

Anonymous
Not applicable

Re: Set Value of {{my.token}} via JavaScript

Hello Sanford,

I have rephrased the question, thanks for the hint.

What I actually attempted is to create some kind of counter for members added to a program. If a certain amount is reached, an alert should be sent to an email address, so that the respective smart campaigns of that program could be deactivated on time. This could be easily achieved if I just create a new custom field, but since this value is rather relevant for the program than for the lead itself, I settled for the my.token.

Since overwriting my.tokens in JavaScript is a huge security issue, is there another possibility to change the value of a my.token and use that afterwards in a smart list? Or at least get the amount of program members and send out an alert, whenever a certain value has been reached?

Thanks in advance

SanfordWhiteman
Level 10 - Community Moderator

Re: Set Value of {{my.token}} via JavaScript

If a certain amount is reached, an alert should be sent to an email address, so that the respective smart campaigns of that program could be deactivated on time. This could be easily achieved if I just create a new custom field, but since this value is rather relevant for the program than for the lead itself, I settled for the my.token.

There are a couple of ways to accomplish this.

  • The way that uses only native Marketo functions (albeit in a hacky-slash-elegant way): create a Resource Contact (RC). This is a Marketo person record that represents the Program itself (it's like when Microsoft Exchange or another collabo platform lists conference rooms and copy machines as resources).  Whenever someone is added to the Program, send out a webhook to the /save endpoint on your instance. This will do a form post on behalf of the RC. A trigger campaign hears those form posts and increments a score field on the RC's record. When score is exceeded, alert, turn off SC, profit, etc.!
  • The way that uses an external service to maintain the counter.  FlowBoost* has a feature designed for this called FBCounter. FBCounter is not only used to add, remove, and count event registrants, it also has the advantage (vs. the RC method) of being readable from the client side, so you can check the current count and redirect the page to an "event full" page automatically (even if the SC is still running).

You might want to try the RC method first and see how it works out for you. I'm rather a fan of it really (AFAIK, I came up with the concept!).

* I'm the tech lead of the FlowBoost platform.