Skip to main content
RapidDev - Software Development Agency
lovable-integrationsEdge Function Integration

How to Integrate Lovable with Drip

To integrate Drip with Lovable, store your Drip API token and Account ID in Cloud → Secrets, then create an Edge Function that proxies calls to the Drip REST API. Drip's strength is e-commerce email CRM — subscriber event tracking, purchase attribution, and workflow triggers. Unlike Klaviyo which requires deep Shopify integration, Drip works with any e-commerce setup through custom events sent from your Lovable Edge Function.

What you'll learn

  • How to find your Drip API token and Account ID and store them in Lovable Cloud → Secrets
  • How to create an Edge Function that creates or updates Drip subscribers with custom fields and tags
  • How to track e-commerce events (purchases, cart abandonment, product views) via the Drip events API
  • How to trigger Drip workflow automations from Lovable frontend actions
  • When to use Drip versus Klaviyo or Mailchimp for indie e-commerce email marketing
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate16 min read30 minutesMarketingMarch 2026RapidDev Engineering Team
TL;DR

To integrate Drip with Lovable, store your Drip API token and Account ID in Cloud → Secrets, then create an Edge Function that proxies calls to the Drip REST API. Drip's strength is e-commerce email CRM — subscriber event tracking, purchase attribution, and workflow triggers. Unlike Klaviyo which requires deep Shopify integration, Drip works with any e-commerce setup through custom events sent from your Lovable Edge Function.

Add e-commerce email CRM and event tracking to Lovable with Drip

Drip positions itself as the e-commerce CRM for independent online businesses — the platform between basic email marketing tools like Mailchimp and enterprise solutions like Klaviyo. Its core differentiator is revenue attribution: Drip tracks which emails, automations, and workflows generated actual purchases, so you know which communication is driving revenue rather than just opens and clicks. For indie e-commerce stores, DTC brands, and digital product creators built on Lovable, this attribution data is the foundation of profitable email marketing.

Lovable has no native Drip connector, so the integration flows through an Edge Function. Your Lovable app sends subscriber data and custom events to the Edge Function; the function calls the Drip REST API to record the subscriber and event; Drip uses that event data to trigger automations, update segments, and attribute revenue. The architecture is event-driven by design — rather than just adding an email address to a list, you send structured events (purchased_product, viewed_pricing, started_checkout) that Drip uses to make decisions about which emails to send.

Drip's API v2 uses simple Bearer token authentication. Your API token authenticates every request, and your Account ID appears in all API endpoint URLs. Tags and custom fields provide the segmentation layer — tags are simple labels (e.g., 'customer', 'vip', 'churned') while custom fields store structured data (lifetime_value, last_purchase_date, plan_tier). This guide covers the complete setup from credentials to a working purchase event tracking implementation.

Integration method

Edge Function Integration

Drip has no native Lovable connector. Subscriber management, custom event tracking, and workflow triggers are handled via a Lovable Edge Function that calls the Drip REST API. The API token and Account ID are stored in Cloud → Secrets and accessed via Deno.env.get(), keeping credentials server-side and enabling e-commerce event attribution from your Lovable app.

Prerequisites

  • A Lovable project with Lovable Cloud enabled (Edge Functions require Lovable Cloud)
  • A Drip account — 14-day free trial with full API access (drip.com)
  • Your Drip API token (Drip → User Settings → API token) and your Account ID (visible in any Drip URL as a number like /12345/)
  • At least one Drip Workflow or automation configured to respond to the events you plan to send (optional but needed to see the full value of event tracking)
  • Basic understanding of how Drip's event-based automation model works — events trigger workflow enrollments, not just list additions

Step-by-step guide

1

Get your Drip API token and Account ID

Gather the two authentication values from Drip: your API token and your Account ID. To find your API token: log in to Drip and click your account name in the top-right corner of the dashboard. Go to User Settings (this is your personal user settings, not the account settings). Scroll down to find the API Token section. Click 'Copy' to copy your API token. This token is a long string that authenticates your API requests. It is tied to your user account, not your Drip workspace — if you have multiple workspaces, the same token works across all of them. To find your Account ID: look at any URL in your Drip dashboard while logged in. The Account ID is the first number in the URL path after the domain — for example, in https://www.getdrip.com/12345678/subscribers, your Account ID is 12345678. This number appears in every Drip API endpoint URL as a path parameter. Drip's API endpoint pattern is https://api.getdrip.com/v2/{account_id}/endpoint — for example, to create a subscriber in account 12345678, you POST to https://api.getdrip.com/v2/12345678/subscribers. Having your Account ID ready means you do not need to look up the URL structure for each endpoint. Optionally, note any existing tags you use in Drip that you want to apply to subscribers added via the Lovable integration. Tags in Drip are case-sensitive strings.

Pro tip: Your Drip API token appears only once in the User Settings page (not the Account Settings). If you have Drip open in multiple tabs, check that you are copying from User Settings (your profile menu) and not from a different settings area — Account Settings shows billing and general configuration, not the API token.

Expected result: You have your Drip API token (a long alphanumeric string) and Account ID (a numeric string from the Drip dashboard URL) ready to store as secrets.

2

Add Drip credentials to Lovable Cloud Secrets

Store your Drip credentials securely in Lovable's Cloud Secrets panel. In your Lovable project, click the '+' icon at the top of the editor to open the Cloud panel. Click the 'Secrets' tab and add the following secrets. First secret — Name: DRIP_API_TOKEN, Value: your Drip API token. This goes in the Authorization header as 'Bearer {token}' for every API request. Second secret — Name: DRIP_ACCOUNT_ID, Value: your numeric Account ID (e.g., 12345678). This is used to construct the API endpoint URLs — every Drip API URL contains your account ID in the path. Drip's authentication model is standard Bearer token auth. The Authorization header is 'Bearer your-api-token'. Unlike Mailchimp's Basic auth or Campaign Monitor's unusual Basic auth pattern, Drip's auth is straightforward and will be familiar if you have worked with other modern REST APIs. Store only the token and account ID in secrets. Do not store segment IDs, tag names, or event action names as secrets — these are not sensitive values and can be referenced directly in your Edge Function code or as parameters from your frontend.

Pro tip: If you have multiple Drip workspaces (e.g., separate accounts for different Lovable apps), create separate secret sets with suffixes: DRIP_API_TOKEN_STORE1, DRIP_ACCOUNT_ID_STORE1, DRIP_API_TOKEN_STORE2, DRIP_ACCOUNT_ID_STORE2. Reference the correct pair in each Edge Function.

Expected result: DRIP_API_TOKEN and DRIP_ACCOUNT_ID appear in your Cloud → Secrets panel with values masked.

3

Create the Drip subscriber and event tracking Edge Function

Create the Edge Function that manages Drip subscribers and tracks e-commerce events. Drip's API v2 has two key endpoints for this integration: POST /v2/{account_id}/subscribers for creating or updating subscribers, and POST /v2/{account_id}/events for tracking custom events. The subscriber endpoint accepts email (required), first_name, last_name, tags (array of strings), and custom_fields (object with key-value pairs for any custom data you want to associate with the subscriber). Setting new_email to a new value updates the subscriber's email address. The API creates a new subscriber if the email does not exist, or updates the existing subscriber if it does. The event endpoint is how Drip integrations become more powerful than basic email marketing. Each event has an action (e.g., 'purchased', 'viewed_pricing', 'cart_abandoned'), optional properties (any key-value pairs you want to associate with the event), and optionally an occurred_at timestamp. Drip uses these events to enroll subscribers into workflows, update their score, and attribute revenue. The action name is how you configure Drip workflow triggers — a workflow set to trigger on 'purchased' will activate whenever your Edge Function fires an event with action: 'purchased'. The Edge Function below handles both subscriber creation and event tracking with a single action parameter, keeping your frontend code clean.

Lovable Prompt

Create an Edge Function called drip-crm at supabase/functions/drip-crm/index.ts that handles two actions: action='create-subscriber' creates or updates a Drip subscriber, and action='track-event' sends a custom event. Use DRIP_API_TOKEN (Bearer auth) and DRIP_ACCOUNT_ID from Deno env to build API URLs. For subscribers, call POST /v2/{accountId}/subscribers. For events, call POST /v2/{accountId}/events. Include CORS headers and return the Drip API response.

Paste this in Lovable chat

supabase/functions/drip-crm/index.ts
1import { serve } from 'https://deno.land/std@0.168.0/http/server.ts'
2
3const corsHeaders = {
4 'Access-Control-Allow-Origin': '*',
5 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
6}
7
8serve(async (req) => {
9 if (req.method === 'OPTIONS') {
10 return new Response('ok', { headers: corsHeaders })
11 }
12
13 try {
14 const body = await req.json()
15 const { action } = body
16
17 const apiToken = Deno.env.get('DRIP_API_TOKEN')
18 const accountId = Deno.env.get('DRIP_ACCOUNT_ID')
19
20 if (!apiToken || !accountId) {
21 throw new Error('Missing required secrets: DRIP_API_TOKEN and DRIP_ACCOUNT_ID')
22 }
23
24 const headers = {
25 Authorization: `Bearer ${apiToken}`,
26 'Content-Type': 'application/json',
27 }
28 const baseUrl = `https://api.getdrip.com/v2/${accountId}`
29
30 if (action === 'create-subscriber') {
31 const { email, firstName = '', lastName = '', tags = [], customFields = {} } = body
32 if (!email) throw new Error('email is required for create-subscriber')
33
34 const payload = {
35 subscribers: [
36 {
37 email,
38 first_name: firstName,
39 last_name: lastName,
40 tags,
41 custom_fields: customFields,
42 },
43 ],
44 }
45
46 const res = await fetch(`${baseUrl}/subscribers`, {
47 method: 'POST',
48 headers,
49 body: JSON.stringify(payload),
50 })
51
52 const data = await res.json()
53 if (!res.ok) throw new Error(`Drip subscriber error: ${JSON.stringify(data)}`)
54
55 const subscriber = data.subscribers?.[0]
56 return new Response(
57 JSON.stringify({ success: true, id: subscriber?.id, email: subscriber?.email }),
58 { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
59 )
60 }
61
62 if (action === 'track-event') {
63 const { email, eventAction, properties = {} } = body
64 if (!email || !eventAction) throw new Error('email and eventAction are required for track-event')
65
66 const payload = {
67 events: [
68 {
69 email,
70 action: eventAction,
71 properties,
72 occurred_at: new Date().toISOString(),
73 },
74 ],
75 }
76
77 const res = await fetch(`${baseUrl}/events`, {
78 method: 'POST',
79 headers,
80 body: JSON.stringify(payload),
81 })
82
83 // Drip events API returns 204 No Content on success
84 if (!res.ok) {
85 const data = await res.json().catch(() => ({}))
86 throw new Error(`Drip event error: ${JSON.stringify(data)}`)
87 }
88
89 return new Response(
90 JSON.stringify({ success: true, message: `Event '${eventAction}' tracked for ${email}` }),
91 { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
92 )
93 }
94
95 throw new Error(`Unknown action: ${action}. Use 'create-subscriber' or 'track-event'.`)
96 } catch (error) {
97 return new Response(
98 JSON.stringify({ error: error.message }),
99 { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
100 )
101 }
102})

Pro tip: Drip's events API returns 204 No Content on success — there is no response body to parse. Make sure your Edge Function checks for both 200/201 and 204 as success status codes for the events endpoint, as shown in the code above.

Expected result: The drip-crm Edge Function is deployed. Test it by invoking create-subscriber with your own email — verify you appear in Drip → Subscribers. Test track-event with action 'test_event' and verify it appears in Drip → Events for that subscriber.

4

Connect purchase events from your Lovable e-commerce flow

Wire the Drip event tracking into your Lovable app's e-commerce flow. The most impactful integration point is after a successful payment — when a user completes a purchase via Stripe (or another payment processor), fire a 'purchased' event to Drip with the order details. This event is what Drip uses to attribute revenue to email campaigns and trigger post-purchase workflows. A good purchase event payload includes: the product name or ID, the purchase amount, the order or transaction ID (for deduplication — Drip can filter duplicate events by occurrence ID), and any tags that indicate the product category or customer tier. The properties object is flexible — include whatever data is valuable for segmentation in your Drip workflows. For cart abandonment, the integration point is detecting when a user leaves the checkout page without completing payment. In React, you can use a useEffect cleanup function or a beforeunload event listener to fire the cart_abandoned event when the user navigates away from an incomplete checkout. Be careful with debouncing — you only want to fire this event once per cart state, not every time the component renders. After wiring up these events, configure Drip workflows to respond to them: a 'purchased' trigger workflow for post-purchase sequences, and a 'cart_abandoned' trigger workflow for recovery emails. The Drip interface for building these workflows is visual and does not require any additional code changes in Lovable.

Lovable Prompt

After a successful Stripe payment in my Lovable app, call the drip-crm Edge Function with action='track-event', the user's email, eventAction='purchased', and properties containing { product_name, amount_cents, order_id, currency: 'usd' }. Also call create-subscriber first if this is their first purchase, adding the tag 'customer'. Handle errors silently — the payment success should not fail if Drip tracking fails.

Paste this in Lovable chat

src/lib/dripTracking.ts
1import { supabase } from '@/lib/supabase'
2
3interface PurchaseEvent {
4 email: string
5 productName: string
6 amountCents: number
7 orderId: string
8}
9
10export const trackDripPurchase = async ({ email, productName, amountCents, orderId }: PurchaseEvent) => {
11 try {
12 // Ensure subscriber exists with 'customer' tag
13 await supabase.functions.invoke('drip-crm', {
14 body: {
15 action: 'create-subscriber',
16 email,
17 tags: ['customer'],
18 customFields: { last_purchase_amount: (amountCents / 100).toFixed(2) },
19 },
20 })
21
22 // Track the purchase event
23 await supabase.functions.invoke('drip-crm', {
24 body: {
25 action: 'track-event',
26 email,
27 eventAction: 'purchased',
28 properties: {
29 product_name: productName,
30 amount_cents: amountCents,
31 order_id: orderId,
32 currency: 'usd',
33 },
34 },
35 })
36 } catch (err) {
37 // Log but do not throw — purchase should succeed regardless of Drip tracking
38 console.error('Drip tracking failed:', err)
39 }
40}

Pro tip: Always call Drip tracking in a try-catch that does not re-throw the error. Email CRM tracking is important but not mission-critical — a Drip API failure should never cause a purchase confirmation page to error out for the user.

Expected result: After a purchase is completed in your Lovable app, the customer appears in Drip with the 'customer' tag and a 'purchased' event in their activity history. If you have a Drip workflow triggered by the 'purchased' event, it activates within minutes.

Common use cases

Track a product purchase and trigger a post-purchase email workflow

When a user completes a purchase in your Lovable app (via Stripe, for example), send a custom event to Drip with the purchase details — product name, amount, order ID. Drip uses this event to trigger a post-purchase automation sequence: an order confirmation, a review request 3 days later, and a repurchase offer 30 days later. The entire sequence runs automatically in Drip after the single event call from your Edge Function.

Lovable Prompt

Create an Edge Function called drip-track-event that accepts { email, event, properties } and sends a custom event to Drip for the subscriber. Use DRIP_API_TOKEN and DRIP_ACCOUNT_ID from secrets. Call POST https://api.getdrip.com/v2/{account_id}/events with Bearer auth. If the subscriber doesn't exist yet, create them first. Then call this from my Stripe payment success handler with event 'purchased' and properties containing the product name and amount.

Copy this prompt to try it in Lovable

Add e-commerce store visitors to Drip with behavioral tags

When a visitor signs up for an account in your Lovable e-commerce app, add them to Drip as a subscriber with tags based on their signup source and initial behavior — whether they came from a paid ad, an organic search, or a referral. Tag-based segmentation in Drip lets you send different onboarding sequences to different acquisition channels, improving conversion rates for each segment.

Lovable Prompt

Create an Edge Function that creates a Drip subscriber when a new user registers. Accept { email, firstName, lastName, tags, customFields } where tags might be ['new-signup', 'organic'] and customFields might include plan: 'free' and signup_source: 'homepage'. Use DRIP_API_TOKEN and DRIP_ACCOUNT_ID. Call POST /v2/{account_id}/subscribers. Apply the tags immediately on creation.

Copy this prompt to try it in Lovable

Record cart abandonment events for abandoned cart email workflows

When a user adds items to their cart but does not complete checkout in your Lovable app, fire a cart_abandoned event to Drip with the cart contents and value. Drip's abandoned cart workflow sends a series of recovery emails — typically within 1 hour, 24 hours, and 3 days — with the cart items and a reminder link. This is one of the highest-ROI email automations for e-commerce.

Lovable Prompt

Create an Edge Function that fires a cart_abandoned event to Drip when a user leaves the checkout page without completing their order. Accept { email, cartValue, cartItems } and send an event with action 'cart_abandoned' and properties including cart_value, item_count, and checkout_url. Use DRIP_API_TOKEN and DRIP_ACCOUNT_ID. This should be called from my checkout page's useEffect cleanup when the component unmounts with an incomplete cart.

Copy this prompt to try it in Lovable

Troubleshooting

Drip API returns 401 Unauthorized for all requests

Cause: The DRIP_API_TOKEN is incorrect, expired, or the Authorization header format is wrong. Drip uses Bearer token auth — the header must be 'Authorization: Bearer {token}', not 'api-key {token}' or Basic auth.

Solution: Go to Drip → User Settings → API Token and copy the current token. Update DRIP_API_TOKEN in Cloud → Secrets and trigger an Edge Function redeployment. Verify the Edge Function constructs the header as: Authorization: `Bearer ${apiToken}` — note the 'Bearer ' prefix with a capital B and a space.

API returns 404 Not Found for subscriber and event endpoints

Cause: The DRIP_ACCOUNT_ID stored in secrets is incorrect. Every Drip API URL includes the account ID in the path (/v2/{accountId}/subscribers), and an incorrect account ID results in a 404 response.

Solution: Log in to Drip and look at the URL in your browser — the account ID is the first number after getdrip.com in the URL path. Update DRIP_ACCOUNT_ID in Cloud → Secrets with the correct numeric ID. Confirm by comparing with the URL format: https://www.getdrip.com/{accountId}/subscribers.

Custom events are tracked but no Drip workflow is triggered

Cause: The event action name in your API call does not match the trigger action name configured in the Drip workflow, or the workflow is in draft mode and not published.

Solution: In Drip, navigate to Automations → Workflows → your workflow → Edit. Check the trigger configuration — the 'Performs an event' trigger must use the exact action string that your Edge Function sends. Event action names are case-sensitive: 'Purchased' and 'purchased' are different triggers. Also verify the workflow is Published (not Draft) — unpublished workflows do not respond to API events.

Subscribers are created but tags are not applied

Cause: Tags must be sent as an array of lowercase strings in the tags field of the subscriber payload. Passing a comma-separated string, an object, or mixed-case tag names that do not match existing Drip tags can cause silent failures.

Solution: Verify tags are passed as an array: tags: ['customer', 'new-signup'] — not as 'customer,new-signup' or { tags: 'customer' }. Tag names in Drip are case-sensitive — 'Customer' and 'customer' are treated as different tags. Check the subscriber's activity in Drip → Subscribers → click subscriber → Activity to see if tags were applied.

Best practices

  • Always fire a create-subscriber call before track-event for new users — Drip can track events for subscribers who do not exist yet, but the subscriber record will be missing name and custom field data unless created explicitly first.
  • Wrap all Drip tracking calls in try-catch that does not re-throw errors — CRM tracking is valuable but should never block user-facing operations like payment confirmation or account creation.
  • Use consistent, lowercase event action names (e.g., 'purchased', 'cart_abandoned', 'viewed_pricing') to make Drip workflow configuration predictable and reduce typo-related trigger failures.
  • Include an order_id or transaction_id in purchase event properties for deduplication — if the same event fires twice due to a retry or double-click, Drip can identify and deduplicate based on a consistent event identifier.
  • Use Drip custom fields for persistent subscriber data (lifetime_value, plan_tier, last_purchase_date) and tags for dynamic segment membership that changes over time (first-time-buyer, churned, vip).
  • Test your event tracking in Drip's activity log (Subscribers → click subscriber → Activity) before configuring live workflows — verify events appear with the correct action names and property values.
  • For high-volume e-commerce apps tracking hundreds of events per day, consider batching events using Drip's bulk events endpoint (POST /v2/{accountId}/events accepts arrays of up to 1000 events) to reduce Edge Function invocation overhead.

Alternatives

Frequently asked questions

How is Drip different from Klaviyo for a Lovable e-commerce app?

Both Drip and Klaviyo are e-commerce email CRMs with event-based automation, but they target different segments. Klaviyo is built for Shopify-heavy stores with large catalogs, deep analytics, and complex segmentation at scale — it starts at $20/month but scales to hundreds of dollars for mid-size stores. Drip is lighter, starts at $39/month for up to 2,500 contacts, and is designed for indie e-commerce stores and digital product creators who want revenue attribution without Klaviyo's complexity. For a Lovable app without Shopify, Drip's flexible REST API is often easier to integrate.

Does Drip have a free tier?

Drip offers a 14-day free trial with full API access. After the trial, the entry-level plan starts at $39/month for up to 2,500 contacts with unlimited email sends. There is no permanent free tier. The pricing scales based on contact count, so for early-stage Lovable apps with small subscriber lists, the base plan is affordable.

Can Drip track revenue from events sent via the API?

Yes, Drip's revenue attribution works by associating purchase events (sent via the events API) with email campaigns and workflows. When you send a 'purchased' event with an amount in the properties, and the subscriber received an email from Drip within a configurable attribution window (default 5 days), Drip attributes that revenue to the email. This attribution data appears in Drip's Reports → Revenue section. The key is including consistent monetary values in your event properties.

What is the difference between Drip tags and custom fields?

Tags in Drip are binary — a subscriber either has a tag or they do not. They are used for segment membership that changes over time, like 'customer' (has made a purchase), 'churned' (cancelled subscription), or 'vip' (high lifetime value). Custom fields store structured data about a subscriber, like their lifetime_value dollar amount, last_purchase_date, or current plan tier. Use tags for dynamic group membership and custom fields for persistent subscriber attributes that inform personalization.

How do I test Drip event tracking without sending to real subscribers?

Use a real email address you control for testing — Drip does not have a sandbox mode. Create a test subscriber with your own email address, fire test events at it, and verify the events appear in Drip → Subscribers → your subscriber → Activity. Once you have confirmed events are firing correctly, you can delete the test subscriber from Drip. Alternatively, use Drip's API explorer in the documentation to test endpoint calls before writing Edge Function code.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.