Learn how to integrate v0 with Campaign Monitor using our step-by-step guide. Boost your email marketing with easy setup and practical automation tips.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
campaignMonitorConfig.ts. This file will store your Campaign Monitor credentials and endpoints.campaignMonitorConfig.ts:
export const CAMPAIGNMONITORAPIKEY = 'YOURCAMPAIGNMONITORAPI_KEY';
export const CAMPAIGNMONITORCLIENTID = 'YOURCAMPAIGNMONITORCLIENT_ID';
export const CAMPAIGNMONITORLISTID = 'YOURCAMPAIGNMONITORLIST_ID';
export const CAMPAIGNMONITORBASE_URL = 'https://api.createsend.com/api/v3.2/';
campaignMonitor.ts in your project. This will contain the TypeScript code for interacting with Campaign Monitor.campaignMonitor.ts:
import { CAMPAIGNMONITORAPIKEY, CAMPAIGNMONITORLISTID, CAMPAIGNMONITORBASE_URL } from './campaignMonitorConfig';
// Function to subscribe an email address to a Campaign Monitor list
export async function subscribeEmail(email: string): Promise<void> {
// Construct the endpoint URL. This uses the CreateSend API endpoint for subscribers.
const endpoint = ${CAMPAIGN_MONITOR_BASE_URL}subscribers/${CAMPAIGN_MONITOR_LIST_ID}.json;
// Build the request payload
const payload = {
EmailAddress: email,
ConsentToTrack: 'Yes'
};
// Making a POST request to Campaign Monitor API with Basic Auth.
// Since v0 doesn't have a terminal, we assume all dependencies are available and use native fetch.
try {
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa(CAMPAIGNMONITORAPI_KEY + ':x')
},
body: JSON.stringify(payload)
});
if (!response.ok) {
const errorDetails = await response.text();
throw new Error(Campaign Monitor error: ${errorDetails});
}
console.log('Subscription successful for:', email);
} catch (error) {
console.error('Failed to subscribe email:', error);
}
}
subscribeEmail which sends a POST request to add the given email to your Campaign Monitor list.
main.ts or similar).subscribeEmail function from the campaignMonitor.ts module:
import { subscribeEmail } from './campaignMonitor';
document.getElementById('subscribeForm')?.addEventListener('submit', async (event) => {
event.preventDefault();
const emailInput = document.getElementById('email') as HTMLInputElement;
if (!emailInput || !emailInput.value) {
alert('Please provide a valid email address.');
return;
}
await subscribeEmail(emailInput.value);
alert('Subscription process initiated. Check the console for details.');
});
subscribeForm and an input field with the id email for proper event handling.
fetch API and Base64 encoding via btoa, which are built into modern browsers. No additional package installations are needed.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.