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

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 */