Search.../

getCampaign( )

Developer Preview

Retrieves information about an email campaign by the specified ID.

Description

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 getCampaign(campaignId: string, options: GetCampaignOptions): Promise<GetCampaignResponse>

getCampaign Parameters

NAME
TYPE
DESCRIPTION
campaignId
string

Campaign ID.

options
Optional
GetCampaignOptions

Options to use when getting a campaign.

Returns

Return Type:

Promise<
GetCampaignResponse
>
NAME
TYPE
DESCRIPTION
campaign
Campaign

Campaign information.

Was this helpful?

Gets email campaign by ID (dashboard page code)

Copy Code
1import { campaigns } from 'wix-email-marketing.v2';
2
3// Sample campaignId value: 'ff61204b-b19a-5cc8-823b-7eed8ae5fc28'
4
5// Sample options value:
6// {
7// optionIncludeStatistics: true,
8// }
9
10export async function myGetCampaignFunction(campaignId, options) {
11 try {
12 const result = campaigns.getCampaign(campaignId, options);
13
14 console.log('Success! Retrieved results:', result);
15 return result;
16 } catch (error) {
17 console.error(error);
18 }
19 }
20
21/* Promise resolves to:
22 * {
23 * "campaign":{
24 * "campaignId": "b98a4436-10f5-47bd-9c6f-370962adfe54",
25 * "title": "A New Tutorial for You",
26 * "firstImageUrl": "https://static.wixstatic.com/media/6191b8_77d27f7d028a4b50850b7f92dadcd578~mv2.png",
27 * "snapshotImageUrl": "https://images-wixmp-678e81504367d310e9a2f32f.wixmp.com/images/b98a4436-10f5-47bd-9c6f-370962adfe54-14dc2505-9fa6-461f-ad70-22358e1428c4",
28 * "editorType": "WEB",
29 * "status": "ACTIVE",
30 * "visibilityStatus": "PUBLISHED",
31 * "distributionStatus": "DISTRIBUTED",
32 * "publishingData": {
33 * "landingPageUrl": "https://shoutout.wix.com/so/54OdUqUrf?languageTag=en",
34 * "statistics": {
35 * "landingPage": {
36 * "opened": 150,
37 * "clicked": 80
38 * },
39 * "emailCampaign": {
40 * "delivered": 700,
41 * "opened": 200,
42 * "clicked": 0,
43 * "bounced": 0,
44 * "complained": 0,
45 * "notSent": 0
46 * },
47 * "total": {
48 * "mailsSent": 1,
49 * "opened": 200,
50 * "clicked": 500
51 * }
52 * },
53 * "datePublished": "2023-08-10T09:40:59.000Z",
54 * "wasResentToNonOpeners": false
55 * },
56 * "dateCreated": "2023-08-10T09:40:47.000Z",
57 * "dateUpdated": "2023-08-10T09:40:59.045Z",
58 * "sendingState": "SENT",
59 * "campaignType": "EMAIL_MARKETING"
60 * }
61 * }
62 */
Gets email campaign by ID (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { campaigns } from 'wix-email-marketing.v2';
3
4// Sample campaignId value: 'ff61204b-b19a-5cc8-823b-7eed8ae5fc28'
5
6// Sample options value:
7// {
8// optionIncludeStatistics: true,
9// }
10
11export const myGetCampaignFunction = webMethod(Permissions.Anyone, async (campaignId, options) => {
12 try {
13 const result = campaigns.getCampaign(campaignId, options);
14
15 console.log('Success! Retrieved results:', result);
16 return result;
17 } catch (error) {
18 console.error(error);
19 }
20});
21
22/* Promise resolves to:
23 * {
24 * "campaign":{
25 * "campaignId": "b98a4436-10f5-47bd-9c6f-370962adfe54",
26 * "title": "A New Tutorial for You",
27 * "firstImageUrl": "https://static.wixstatic.com/media/6191b8_77d27f7d028a4b50850b7f92dadcd578~mv2.png",
28 * "snapshotImageUrl": "https://images-wixmp-678e81504367d310e9a2f32f.wixmp.com/images/b98a4436-10f5-47bd-9c6f-370962adfe54-14dc2505-9fa6-461f-ad70-22358e1428c4",
29 * "editorType": "WEB",
30 * "status": "ACTIVE",
31 * "visibilityStatus": "PUBLISHED",
32 * "distributionStatus": "DISTRIBUTED",
33 * "publishingData": {
34 * "landingPageUrl": "https://shoutout.wix.com/so/54OdUqUrf?languageTag=en",
35 * "statistics": {
36 * "landingPage": {
37 * "opened": 150,
38 * "clicked": 80
39 * },
40 * "emailCampaign": {
41 * "delivered": 700,
42 * "opened": 200,
43 * "clicked": 0,
44 * "bounced": 0,
45 * "complained": 0,
46 * "notSent": 0
47 * },
48 * "total": {
49 * "mailsSent": 1,
50 * "opened": 200,
51 * "clicked": 500
52 * }
53 * },
54 * "datePublished": "2023-08-10T09:40:59.000Z",
55 * "wasResentToNonOpeners": false
56 * },
57 * "dateCreated": "2023-08-10T09:40:47.000Z",
58 * "dateUpdated": "2023-08-10T09:40:59.045Z",
59 * "sendingState": "SENT",
60 * "campaignType": "EMAIL_MARKETING"
61 * }
62 * }
63 */
64