# Mailchimp new subscriber notifications on your phone > Get a low-priority push notification when someone subscribes to your Mailchimp audience, with their name and email. - Company: Mailchimp (https://www.justpush.io/recipes/mailchimp) - Event: `subscribe` (Email subscribes) - Tags: Email marketing, Newsletters, Sign-ups & users - Install: https://studio.justpush.io/recipes/mailchimp/new-subscriber - Web page: https://www.justpush.io/recipes/mailchimp/new-subscriber ## Setup 1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL. 2. In Mailchimp, open Audience, pick your audience, then More options > Audience settings > Manage webhooks and click Create webhook. 3. Paste your webhook URL (shown in Studio after install) as the Callback URL. Mailchimp checks it with a quick GET, which JustPush accepts silently. 4. Tick only Email subscribes under the update types, keep all three sources ticked, and click Create webhook. 5. Mailchimp only sends the audience's ID, not its name. To show the name in the push, add it to the Callback URL: 6. ``` 7. your webhook URL (shown in Studio after install)?audience=Weekly%20Newsletter 8. ``` 9. (`%20` is a space.) Leave it out and the push says "your audience". 10. Mailchimp checks the URL with a GET request when you save the webhook. The recipe answers it without sending a push. 11. Mailchimp can sign deliveries (`X-Mailchimp-Signature`) and shows a signing secret once after you save. JustPush doesn't check that signature yet, so you can dismiss the secret and keep your endpoint URL private. ## Code Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing. ```js // Mailchimp → subscribe (new subscriber) // Fires when someone subscribes to a Mailchimp audience, through a signup form, // an admin adding them, or the API. // Docs: https://mailchimp.com/developer/marketing/guides/sync-audience-data-webhooks/ // // Mailchimp POSTs form-encoded fields such as type=subscribe, data[email]=…, // data[merges][FNAME]=…. Depending on how the body was parsed, it can arrive as a // nested object, a flat object with bracket keys, or only as the raw string. // Keys that must never become object properties. const UNSAFE = new Set(["__proto__", "constructor", "prototype"]) // Put a value at a bracket path such as data[merges][FNAME]. function setPath(target, key, value) { const parts = String(key).replace(/\]/g, "").split("[") if (parts.some((p) => p === "" || UNSAFE.has(p))) return let node = target for (const part of parts.slice(0, -1)) { if (!node[part] || typeof node[part] !== "object") node[part] = {} node = node[part] } node[parts[parts.length - 1]] = value } // Decode one form-encoded piece; a bad escape shouldn't break the whole body. function decode(value) { try { return decodeURIComponent(String(value).replace(/\+/g, " ")) } catch { return String(value) } } // Turn whatever Studio gives us into { type, fired_at, data: { … } }. function readForm(request) { const body = request.body const out = {} if (body && typeof body === "object" && !Array.isArray(body)) { // Nested keys are copied as they are; bracket keys are expanded. for (const [key, value] of Object.entries(body)) { if (key.includes("[")) setPath(out, key, value) else if (!UNSAFE.has(key)) out[key] = value } if (out.type) return out } // Fall back to the raw form-encoded string. const raw = typeof request.raw === "string" ? request.raw : typeof body === "string" ? body : "" if (raw.includes("=")) { for (const pair of raw.split("&")) { const at = pair.indexOf("=") if (at > 0) setPath(out, decode(pair.slice(0, at)), decode(pair.slice(at + 1))) } } return out } // Form fields are strings; treat blanks as missing. function text(value) { return typeof value === "string" && value.trim() ? value.trim() : null } function handleRequest(request) { // Mailchimp checks the callback URL with a GET when you save the webhook. if (String(request.method ?? "").toUpperCase() === "GET") { console.log("Mailchimp URL check (GET) — nothing to send") return null } const form = readForm(request) const data = form.data && typeof form.data === "object" ? form.data : {} // Guard: only subscribes, so other update types on this webhook stay quiet. if (form.type !== "subscribe") { console.log(`Ignoring Mailchimp "${form.type ?? "unknown"}" update`) return null } const merges = data.merges && typeof data.merges === "object" ? data.merges : {} const email = text(data.email) ?? text(merges.EMAIL) const name = [text(merges.FNAME), text(merges.LNAME)].filter(Boolean).join(" ") const who = name && email ? `${name} (${email})` : name || email || "Someone" // Mailchimp only sends the audience ID, so ?audience=Newsletter names it for you. const audience = text(request.query?.audience) return { title: "📬 New subscriber", message: `${who} joined ${audience ?? "your audience"}`, topic: "Mailchimp", priority: -1, // Low — good news, nothing to do } } ``` ## Mailchimp subscribe webhook payload (sample) ```json { "data": { "id": "8a25ff1d98", "email": "ada@example.com", "ip_opt": "203.0.113.10", "merges": { "EMAIL": "ada@example.com", "FNAME": "Ada", "LNAME": "Lovelace", "INTERESTS": "Weekly digest" }, "list_id": "a6b5da1054", "ip_signup": "203.0.113.10", "email_type": "html" }, "type": "subscribe", "fired_at": "2026-09-29 09:35:57" } ``` ## FAQ ### Does this work on iPhone and Android? Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification. ### Do I need to write code? No. Install the recipe in Studio, paste your webhook URL into Mailchimp and you are done. The code is there if you want to change the text, the sound or the buttons. ### Can I change what the notification says? Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save. ### What does it cost? JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.