Skip to content
A8 Labs

How to Parse Stripe Metadata in HubSpot

Utilize Stripe metadata in HubSpot to enrich your data. In this article, we will cover how Zaybra syncs Stripe metadata to HubSpot and how to parse it.

Parse Stripe Metadata in HubSpot

What is Stripe Metadata?

In addition to the standard properties of a Stripe object, metadata offers a flexible and powerful means of storing additional information. This information can be anything from a unique identifier to additional data that you want to track. 


No matter the reason for storing metadata in Stripe, this information can often help enrich your HubSpot data. Zaybra makes it easy to sync metadata associated with customers, subscriptions, and transactions to your HubSpot records.

In this article, we will cover how to separate (parse) Stripe metadata in HubSpot.

How does Zaybra sync metadata to HubSpot?

Because metadata fields can vary greatly between object types, individual records, and use cases, Zaybra does not create a property for each possible metadata field.

Instead, Zaybra syncs all metadata fields on stripe Customers, Subscriptions, and Transactions to a HubSpot property on the relevant record.

Giving you full control to determine which properties and values are placed where.

How to Parse Stripe Metadata in a HubSpot Workflow:

Since Zaybra syncs all Stripe metadata fields to a single property, you will need to utilize a HubSpot Custom Coded Workflow Action to parse the values. 

Metadata will enter the workflow in this format:


And the values will leave nicely nested in a HubSpot Property!


1. Create your workflow:

Depending on the type of object you are parsing metadata for, you will need to create a workflow based on that object. In this example, we will be creating a Zaybra Subscription based workflow

2. Set your Enrollment Triggers:

Set the workflow enrollment trigger to " Subscription Metadata is Known"  if you want the metadata to parse when the object is created.

Set "Subscription Metadata has been updated in the last 1 day" and turn on re-enrollments if you want subscription metadata to update anytime it's updated in Stripe. 

3. Create a Custom Coded Action

Set the following fields:

  • Language: Node.js 16.x
  • Properties to Include (Input Fields):
    •  Subscription Metadata: subscription_metadata
  • Data Outputs: Add an option for each expected output/metadata field.
    • Select the data type and add a name such as "fieldOne". This will be referenced in the code. 
  • Code: Copy and Paste the code below into the code section.
    • Change the value highlighted in red to match your Input Field.
    • Change the values highlighted in yellow to match the metadata field names from Stripe.
    • Change the values highlighted in green to match the name assigned to your Data Output. 
  • Test your custom coded action and address any errors.


exports.main = async (event, callback) => {
 /* When parsing metadata for a Contact or Transaction, change 'subcsription_metadata' to match the input field ('customer_metadata' or 'transaction_metadata') */
	const metaData = JSON.parse(event.inputFields['subscription_metadata']);
 /* To parse additional metadata fields, copy the text below and change the 'change_me' values to match the metadata field name in stripe. 
    const changeMe = metaData['change_me'] ? metaData['field_one'] : null;
    const fieldOne = metaData['field_one'] ? metaData['field_one'] : null;
    const fieldTwo = metaData['field_two'] ? metaData['field_two'] : null;

/* Make sure the outputFields below match the const defined aboove */
      outputFields: {

4. Copy the out to your HubSpot Properties:

Add a Copy Property Value action for each data output. 


In this example, I have added 2 outputs. One for the "fieldOne" output and another for the "fieldTwo" output.

And that's all folks! If you run into any issues in building this or would be interested in us building it for you, do not hesitate to get in touch!





Jonathan Stevens

Jonathan Stevens

Jonathan is a Product Support Specialist at A8 Labs. He helps professionals power up their HubSpot experience by supporting the most powerful apps in the HubSpot marketplace.

Latest Articles

How to improve your revenue recognition?

There are several ways we can improve your revenue recognition and understanding. Let’s have a look at few of them.

Using Zaybra for hosted payments on Hubspot

Zaybra allows its customers to use virtually any payment method that Stripe supports, but without the need of leaving from Hubspot payment ...

3 overlooked reasons your customers are canceling their subscription

Reasons why your customers cancel their subscription can differ. However, not all churn is equal.