This article explains how to send data to Notion via the third party app, Zapier. You can use Zapier to get data into Notion from hundreds of apps using this process. As an example we will use the payment processing app, Stripe.

Example: How to Integrate Stripe with Notion

Many teams discover that while Stripe is a great API layer, it can be a real challenge to get the revenue and plan information exported and available to everyone that needs it on a regular basis. On top of that, many teams generate revenue from different places -- not just Stripe -- making visibility to total revenue even more critical.

That’s where Notion comes in. And you can connect and automate the updating of your SaaS total revenue from Stripe on your Notion dashboards via Zapier.

Before you start

It’s quick to get set up and ready, but first you’ll need:

Importing data monthly from Stripe

Suppose you want to track the total monthly revenue by plan from Stripe. If you have 4 plans that you want to track (eg Small, Medium, Large, and Enterprise), then we’ll create one recipe with 4 ingredients. The ingredients are added together for Total Stripe Revenue.

Create a new monthly recipe in Notion

  • From your Notion Directory or dashboard, select Add Recipe -> Add a new Metric
  • Give your new recipe a name, e.g. “Total Stripe Revenue”. This will be a recipe with four ingredients.
  • Give your new ingredients a name, e.g. “Stripe Revenue Small Plan”, “Stripe Revenue Medium Plan”, etc. Assign it to yourself for now, as we’ll be using the Zapier connection in a moment to send the data.

Set the frequency to monthly. In the example below, I set this to monthly where the period ends on the last day of the month and is added to the chart the day the period ends. We’ve chosen the Horizontal Bar Chart, so we can compare the different payment plans.

Additionally, you can set targets, unlist your recipe, and add it to other dashboards. If you have questions on how to create a Recipe, feel free to contact us.

First step is done! You have a new recipe “Stripe Total Revenue” in your Directory.

Creating a Zap to automate the monthly import

We’ll create the first of two Zaps to store the monthly values using Stripe and Zapier Storage. In the second Zap, we’ll fetch the sum and pass it on to Notion.

Step 1 - Stripe

  • From your Zapier Account, select Make a Zap!.
  • You can name your Zap now or do it later. I’ll call mine Notion / Stripe Total Revenue.
  • For Step 1, choose Stripe as your Trigger App.
  • Select New Charge.
  • Continue if you’ve previously connected your account or connect if you haven’t already authenticated to Stripe.
    • Zapier will fetch a recent transaction and show you the results. Confirm and Continue.
  • Add a Filter step to only process successful charges.
  • Select Only continue if… and Save + Continue.
  • Select New Charge then Status then (Text) Contains. Then type “succeeded” (in lowercase).
  • Save and Continue. The Filter will run and you’ll see the results.

Step 2 - Format the date

We need to do some bookkeeping, so we’ll need to format the month the charge occurred. We can get this from the charge creation date, and we’ll use Zapier formatting to help out here.

  • Select Formatter by Zapier
  • For the Action, select Date / Time.
  • The Transform is Format and the Input is Created Formatted and the To Format will be Use a Custom Value (advanced) and the Custom Value to Format will be YYYY-M.
    • We’ll end up with something like 2017-3 if we did it correctly.
  • The full set up for the date:
  • Continue then Create and Continue. You’ll see the results from the test. Continue.

Step 3 - Store the total charge value

We’ll use Zapier’s built in Storage to keep our values and add them together as charges accumulate. We’ll separate these out by plan.

  • Select Storage by Zapier.
  • Select Show less common options. Then Increment Value. Save + Continue.
  • Select your Storage account or create a new Zapier Storage account.
  • For Key, we’ll create the name as YYYY-DD-Plan Name, so 2017-03-Small as an example.
    • For the Key field Select Date / Time. Select Created Formatted. Type a dash ‘-’.
    • In the same Key field, select New Charge. Select Cust Subscriptions Data Plan Name.
  • For Increment Amount, select New Charge. Then select Amount.

You’re now collecting all the charges from Stripe, filtering them for successful ones, and sorting and storing the totals by year-month and plan. Let’s create our final Zap!

Create a new Zap to Send to Notion

Now that you’re storing up charges from Stripe, we’ll grab those values monthly, in this case, and send those to Notion using the API.

Step 1 - Scheduler

  • From your Zapier Account, select Make a Zap! or from your last Zap, Make another Zap.
  • You can name your Zap now or do it later. I’ll call mine Notion / Stripe Total Revenue Send to Notion.
  • For Step 1, choose Schedule by Zapier as your Trigger App.
  • Select Every Month. Save + Continue.
  • For Day of Month, select 31 (last day of month). Time of Day will be 11pm.
    • Your Zap will fire sometime after 11pm. If you’d like to be more precise and capture the period between 11pm and midnight, then add a delay step.
  • Continue. Fetch & Continue. Continue.

Step 2 - Storage (Lookup values), First Plan

  • Select Storage by Zapier.
  • Select your storage account. Save + Continue.
  • Under Search, select Get Value. We’re going to look up the total monthly plan value in this step. Continue.
  • Select your Storage Account.
  • We’ll now build the key that looks up our value that we stored previously. It’s important that the key matches. The format will follow YYYY-M-Plan Name
    • Select Date Year. Type “-”. Then select Date Month. Type “-”. Then type the name of the first plan you want to retrieve the value for (eg “Small”).

(Note the dashes between items. Key must match what we previously stored.)

  • Select Continue. Test your step and Continue.

Step 3 - Code (Send to Notion), First Plan

OK, last step to send our first plan’s data. Every month, we’ll look up the incremented value in Zapier Storage and we’ll now send that to Notion using the API.

  • Select Add a Step to add the remaining step, Code by Zapier.
  • We’ll be using Javascript, so Run Javascript is our option. Save + Continue.
  • For the Input Data, we’ll be using the value we just looked up from Storage:
    • In the first box on the first row, type value. In the second box, select Step 2 Get Value and then select Value.
    • Hit the + button to add a new row. In the second row, first box, type dateString.
    • In the second box on that second row, select Step 1 Every Month. Select ID.

We’ll now paste in the code that sends everything to Notion in the Code section. Go ahead and paste this code in:


var apiToken = 'your token here';
var ingredientId = 'your ingredient id here';

var payload = {
"ingredient_id" : ingredientId.trim(),
"value" : inputData.value,
"date" : inputData.dateString.substring(0,10)
};

payload = JSON.stringify(payload);
fetch('https://app.usenotion.com/api/v1/report', {
method: 'POST',
body: payload,
headers: {
'Content-Type': 'application/json',
'Authorization' : apiToken.trim(),
}
}).then(function(res) {
var output = res.text();
callback(null, output);
});


  • Now, we’ll need to substitute in your API Token and Ingredient ID at the top of the script. Those values are found in your Notion account.
  • Click here to find your API Token in your Notion API Console. Copy it and return to Zapier and change ‘your token here’ to the value you copied.

Return back to your Notion API Console, and find your Ingredient for the Small Plan. Copy the ID and return to Zapier. Change ‘your ingredient id here’ to the value you copied.

The code with your API Token and Ingredient ID in place will look something like:

var apiToken = 'f63a994958dbdaxxxxxx81f2f1';
var ingredientId = 'gFJpWbdVxxxxxxxeLNuhNvFm';

var payload = {

}
  • Select Continue. Then, Create & Continue. Zapier will run the code with the current time, and if everything is correct, you’ll see a success message.

Now, repeat adding the Get Value from Storage and Code (Send to Notion) steps for each of your plans in this Zap. If you have 4 plans, you’ll add 8 steps in total (Get Value + Code + Get Value + Code + Get Value + Code + Get Value + Code).

  • You can now return to your Notion Directory and confirm that your value -- in our case Missing Pages -- was correctly sent from Google Analytics! Select Finish and turn on your Zap to be run daily.

Hurray! You’ve just set this up:

Wait! You can achieve even more.

You won’t see values start to roll in until the end of the month, and you won’t have correct values until this is running for a full month. But, you can load past historical values for your dashboard with our Notion for Google Sheets Add-on. It’s a great way to get going even faster.

Daily or Weekly

Instead of a monthly schedule, you can easily change change these steps to work for a weekly schedule, by substituting in weekly for monthly. For daily values, I would recommend removing the values from Storage after sending to Notion, so you don’t run out of space.

More questions or need help?

Don’t hesitate to reach out to us at support@usenotion.com or chat us in the app. We love this stuff, and are happy to get you all set up.