How I Automated Campaign Monitor in Zapier Without CSV Parsing (Real-Time JSON FTW)

๐Ÿ”ฅ Stop Parsing CSVs in Zapier: Flatten Campaign Monitor Custom Fields with Real-Time JSON

A one-step JavaScript solution inside Code by Zapier to bypass broken webhook parsing and get clean Campaign Monitor custom fields in real time.

๐Ÿšง The Problem

When using Zapier webhooks with Campaign Monitor, custom fields are often sent as flat CSV-style strings — and if your address or company name has a comma? Everything breaks.

Result: Your subscriber's "Suite 200" ends up in the zip code field. Gross.

๐Ÿง  The Solution

Skip the CSV hell completely. I built a Code by Zapier step that:

  • Calls the Campaign Monitor API directly
  • Authenticates with btoa(apiKey:)
  • Parses real-time JSON
  • Flattens CustomFields into a clean object

No CSV splitting. No duct tape. Just clean data.

๐Ÿ’ป The Code (Inside Zapier)

const apiKey = "YOUR_API_KEY"; const listId = "YOUR_LIST_ID"; const email = inputData.email; const authHeader = btoa(`${apiKey}:`); fetch(`https://api.createsend.com/api/v3.3/subscribers/${listId}.json?email=${encodeURIComponent(email)}`, { method: "GET", headers: { "Authorization": `Basic ${authHeader}`, "Accept": "application/json" } }) .then(res => res.json()) .then(data => { const output = { Email: data.EmailAddress || "", Name: data.Name || "", State: data.State || "", Date: data.Date || "" }; if (data.Name) { const parts = data.Name.trim().split(" "); output["First Name"] = parts[0] || ""; output["Last Name"] = parts.slice(1).join(" ") || ""; } (data.CustomFields || []).forEach(field => { const key = field?.Key?.trim(); const value = field?.Value?.trim(); if (!key || value === undefined) return; if (key.toLowerCase().includes("market segment")) { output["Market Segments"] = output["Market Segments"] || []; output["Market Segments"].push(value); } else { output[key] = value; } }); if (Array.isArray(output["Market Segments"])) { output["Market Segments"] = output["Market Segments"].join(", "); } callback(null, output); }) .catch(err => callback(err));

๐Ÿงพ Example Output

{ "Email": "tim@example.com", "First Name": "Tim", "Last Name": "Spaeth", "State": "Unsubscribed", "Address": "121 S Wilke Rd, Suite 200", "Zip Code": "60005", "Market Segments": "Aerospace, Medical" }

✅ How to Flatten Campaign Monitor Custom Fields in Zapier

This method solves a very real pain point: Zapier’s webhook flattening ruins multi-field custom data. By grabbing JSON directly from Campaign Monitor's API, you maintain structure and avoid hours of CSV debugging.

๐ŸŽฏ Final Thoughts

Stop fighting Zapier’s field flattener.
Stop writing brittle CSV-splitters.
Start using clean JSON from the source.
And automate like you mean it.

#Zapier #CampaignMonitor #CodeByZapier #API #Automation #MarketingOps #CustomFields #RealTimeData

Comments

Popular posts from this blog

Webinar Wisdom: Unveiling Three Essential Insights for Hosting Success

SOS Mode: AT&T Nationwide Outage...Solar Flare? No Service?

A Busy Schedule