简体   繁体   中英

Apps Script: How to use token

I found THIS pretty good explained script HIER to add the unsubscribe option to my mail merger. It´s even recommended by Google. I´ve managed to install it, but I can´t figure out which value I should put in the last curly brace (so, {{TOKEN}} ) in the HTML code below, because this is the first time ever that I work with tokens. Can somebody please help? I mean how would the value for {{TOKEN}} look like? Thanks:)

Here is the HTML code where I need assistance:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <h1>We are testing our unsubscribe feature</h1>
    <a href="{{WEBAPP_URL}}?email={{EMAIL}}&unsubscribe_hash={{TOKEN}}"> Unsubscribe </a>
  </body>
</html>

WHAT?

  • WEBAPP_URL

The url of you web application.

  • EMAIL

The email of the recipient.

  • TOKEN

Possibly a random string (hash) that is generated for each recipient (and may be also each email).


HOW?

The replacement should be done when you are creating the emails.

The exact method depends on the tool (and such language) you use.

Commonly, you need to replace the values with the actual value stored in a variable

Here, I assume it is Google Apps Script.

  var html =  HtmlService.createHtmlOutputFromFile('index');
  var content = html.getContent().replace('{{EMAIL}}',  email);
  /* ... */

An alternative would be to use scriplets .


Reference:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM