View Categories

Integrasi Google Form ke Mailketing

< 1 min read


Script GS :

function setupTriggers() {

  var form = FormApp.getActiveForm();
  ScriptApp.newTrigger("mailketing").forForm(form).onFormSubmit().create();

}
function mailketing(e) {

  try {

    var i = 0,
      lead = {},
      items = e.response.getItemResponses();

      lead.api_token='masukkan api token anda';
      lead.list_id='masukkan list_id';

    for (i = 0; i < items.length; i++) {

      var title = items[i].getItem().getTitle();
      var answer = items[i].getResponse().toString();

      switch (title) {
        case "Email":
          lead.email = answer;
          break;
        case "Nama":
          lead.first_name = answer;
          break;
        case "No Whatsapp":
          lead.mobile = answer;
          break;
      }
    }

    var response = UrlFetchApp.fetch(
      "https://api.mailketing.co.id/api/v1/addsubtolist", {
        method: "POST",
        payload: lead
      }
    );

    Logger.log(response.getContentText());

  } catch (error) {

    Logger.log(error.toString());

  }

}

Leave a Comment

Mailketing by Regrow

PT. Digital Bertuah Nusantara
Jl. Mangga No. 94B
Pekanbaru - Riau
Indonesia

© 2022 mailketing.co.id All rights reserved. ‍