Search...
publishCampaign( )
Developer Preview
Publishes/sends a specified campaign.
Description
If no emailDistributionOptions
parameters are specified, the campaign is only published as a landing page.
This function is not a universal function and runs only on the backend.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function publishCampaign(campaignId: string, options: PublishCampaignOptions): Promise<PublishCampaignResponse>
publishCampaign Parameters
NAME
TYPE
DESCRIPTION
campaignId
string
Campaign ID
options
Optional
PublishCampaignOptions
Options to use when publishing a campaign.
Returns
Return Type:
Promise<
PublishCampaignResponse
>NAME
TYPE
DESCRIPTION
publishingData
PublishingData
publishingData.statistics
will be empty.
Was this helpful?
Publishes specified campaign (dashboard page code)
Copy Code
1import { campaigns } from 'wix-email-marketing.v2';23// Sample campaignId = "ea46013c-bbbf-4617-ad5d-9247bc4c0970";45export async function myPublishCampaignFunction(campaignId) {6 try {7 const result = await campaigns.publishCampaign(campaignId);89 console.log(`Success! Your campaign with id: ${campaignId} has been published.`)10 return result;11 } catch (error) {12 console.error(error);13 }14}1516/* Promise resolves to:17 * {18 * "publishingData": {19 * "landingPageUrl": "https://shoutout.wix.com/so/88OduoI8E?languageTag=en",20 * "datePublished": "2023-08-17T11:11:06.000Z",21 * "wasResentToNonOpeners": false,22 * "statistics": {23 * "landingPage": {24 * "opened": 150,25 * "clicked": 8026 * },27 * "emailCampaign": {28 * "opened": 200,29 * "clicked": 0,30 * "bounced": 0,31 * "complained": 0,32 * "notSent": 033 * },34 * "total": {35 * "mailsSent": 1,36 * "opened": 200,37 * "clicked": 50038 * }39 * }40 * }41 * }42 */
Publishes specified campaign (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { campaigns } from 'wix-email-marketing.v2';34// Sample campaignId = "ea46013c-bbbf-4617-ad5d-9247bc4c0970";56export const myPublishCampaignFunction = webMethod(Permissions.Anyone, async (campaignId) => {7 try {8 const result = await campaigns.publishCampaign(campaignId);910 console.log(`Success! Your campaign with id: ${campaignId} has been published.`)11 return result;12 } catch (error) {13 console.error(error);14 }15});1617/* Promise resolves to:18 * {19 * "publishingData": {20 * "landingPageUrl": "https://shoutout.wix.com/so/88OduoI8E?languageTag=en",21 * "datePublished": "2023-08-17T11:11:06.000Z",22 * "wasResentToNonOpeners": false,23 * "statistics": {24 * "landingPage": {25 * "opened": 150,26 * "clicked": 8027 * },28 * "emailCampaign": {29 * "opened": 200,30 * "clicked": 0,31 * "bounced": 0,32 * "complained": 0,33 * "notSent": 034 * },35 * "total": {36 * "mailsSent": 1,37 * "opened": 200,38 * "clicked": 50039 * }40 * }41 * }42 * }43 */44