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';
2
3// Sample campaignId = "ea46013c-bbbf-4617-ad5d-9247bc4c0970";
4
5export async function myPublishCampaignFunction(campaignId) {
6 try {
7 const result = await campaigns.publishCampaign(campaignId);
8
9 console.log(`Success! Your campaign with id: ${campaignId} has been published.`)
10 return result;
11 } catch (error) {
12 console.error(error);
13 }
14}
15
16/* 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": 80
26 * },
27 * "emailCampaign": {
28 * "opened": 200,
29 * "clicked": 0,
30 * "bounced": 0,
31 * "complained": 0,
32 * "notSent": 0
33 * },
34 * "total": {
35 * "mailsSent": 1,
36 * "opened": 200,
37 * "clicked": 500
38 * }
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';
3
4// Sample campaignId = "ea46013c-bbbf-4617-ad5d-9247bc4c0970";
5
6export const myPublishCampaignFunction = webMethod(Permissions.Anyone, async (campaignId) => {
7 try {
8 const result = await campaigns.publishCampaign(campaignId);
9
10 console.log(`Success! Your campaign with id: ${campaignId} has been published.`)
11 return result;
12 } catch (error) {
13 console.error(error);
14 }
15});
16
17/* 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": 80
27 * },
28 * "emailCampaign": {
29 * "opened": 200,
30 * "clicked": 0,
31 * "bounced": 0,
32 * "complained": 0,
33 * "notSent": 0
34 * },
35 * "total": {
36 * "mailsSent": 1,
37 * "opened": 200,
38 * "clicked": 500
39 * }
40 * }
41 * }
42 * }
43 */
44