Perk.Exchange
  • ☕Overview
  • 🛫Onboarding
  • 🕵️Privacy Policy
  • Socials
  • 💰Tipping
  • 📣Promotions
    • Community Promotion
  • 🛠️Integrations
    • Discord
    • Telegram
    • Zapier
    • GitHub
    • Freshdesk
    • Google Forms
    • Zendesk
    • Atlassian Jira
    • 📽️Streaming
  • 🎁TIP
    • 🔄Get TIP
    • 🎯Goals
Powered by GitBook
On this page
  • Create a Promotion Token
  • Open the Form Script Editor
  • Add a "OnSubmit" function

Was this helpful?

  1. Integrations

Google Forms

Give KIN to respondents by triggering an invoice when a form is submitted

PreviousFreshdeskNextZendesk

Last updated 7 months ago

Was this helpful?

Create a Promotion Token

Steps:

  1. Create a

  2. Copy a promotion token and keep it safe. Use it in place of XXXXXXXX in the script below.

Open the Form Script Editor

Add a "OnSubmit" function

Copy/paste the following function to the code section. This code should run when the form is submitted.

var POST_URL = "https://perk.exchange/api/perks";
var CAMPAIGN_SECRET = 'XXXXXXXX'

function onSubmit(e) {
    var form = FormApp.getActiveForm();

    var allResponses = form.getResponses();
    var latestResponse = allResponses[allResponses.length - 1];
    var response = latestResponse.getItemResponses();
    var userEmail = latestResponse.getRespondentEmail()
    var payload = {"user_id": userEmail, "platform": "email", "url": "https://perk.exchange"};
  
    var options = {
headers:{
       "x-perk-token": CAMPAIGN_SECRET
  }, 
        "method": "post",
        "contentType": "application/json",
        "payload": JSON.stringify(payload)
    };
    UrlFetchApp.fetch(POST_URL, options);
};

🛠️
promotion
Choose "Script Editor"