> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Package: emailMarketing # Namespace: campaign # Webhook link: https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/campaign-created.md ## Introduction Triggered when a campaign is created. --- ## REST API ### Schema ``` Webhook: Campaign Created Description: Triggered when a campaign is created. Event body: - name: id | type: string | description: Unique event ID. Allows clients to ignore duplicate events. - name: entityFqdn | type: string | description: Fully qualified domain name of the entity associated with the event. - name: slug | type: string | description: Event name. - name: entityId | type: string | description: ID of the entity associated with the event. - name: eventTime | type: string (date-time) | description: Event timestamp. - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application such as GDPR. - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event. - name: createdEvent | type: object | description: Created event details. - name: entity | type: Campaign | description: The created entity. - name: campaignId | type: string | description: Campaign GUID. - name: title | type: string | description: Marketing campaign title. If you don't provide the value, the title automatically gets the value of an email subject. - name: firstImageUrl | type: string | description: URL of the first image after the logo. - name: editorType | type: Enum | description: Editor type. - enum: - UNKNOWN: Unknown editor. This value isn't used. - WEB: Classic web editor. - MOBILE: Classic mobile editor. - MJML: Chat (AI) based web editor. - name: status | type: Enum | description: Campaign status. - enum: - UNKNOWN: Unknown campaign. This value isn't used. - ACTIVE: Campaign is active. - ARCHIVED: Campaign is archived. - DELETED: Campaign is deleted. - name: visibilityStatus | type: Enum | description: Campaign visibility status. - enum: - UNKNOWN: Unknown status. This value isn't used. - DRAFT: Campaign isn't published yet. - PUBLISHED: Campaign is published. - TEMPLATE: Campaign is a template. - name: distributionStatus | type: Enum | description: Campaign distribution status. - enum: - UNKNOWN: Unknown distribution status. - NOT_STARTED: Campaign isn't distributed to recipients yet. - SCHEDULED: Campaign is scheduled for distribution. - IN_DETECTION: Campaign is in screening for malicious content. - IN_MODERATION: Campaign is in review by the site moderators. - SAMPLING: Several recipients are selected for campaign testing, and campaign is sent out to them. - SENDING: Campaign is being sent out to all recipients. - REJECTED: Campaign is rejected. - TERMINATED: Campaign is terminated after a failed sampling test. - DISTRIBUTED: Campaign is fully distributed to all recipients. - PAUSED: Scheduled campaign is paused. - name: publishingData | type: PublishingData | description: Publishing data. The field is returned empty if the campaign isn't published. - name: landingPageUrl | type: string | description: Landing page URL. - name: statistics | type: CampaignStatistics | description: Marketing campaign statistics. - name: landingPage | type: LandingPageStatistics | description: Landing page statistics of a marketing campaign. - name: opened | type: integer | description: Number of times when a landing page was loaded or viewed. - name: clicked | type: integer | description: Number of times a link was clicked in a landing page. - name: emailCampaign | type: DistributionStatistics | description: Email distribution statistics of a marketing campaign. - name: delivered | type: integer | description: Number of delivered emails. - name: opened | type: integer | description: Number of recipients who opened an email. If the same recipient opened the same email twice, it is counted as a one unique open. - name: clicked | type: integer | description: Number of recipients who clicked a link in the email. If the same recipient clicked the same link twice, it is counted as a one unique click. If the same recipient clicked different links, it is counted as a one unique click. - name: bounced | type: integer | description: Number of emails that didn't reach the recipient. - name: complained | type: integer | description: Number of recipients who reported the email as a spam. - name: notSent | type: integer | description: Number of emails that weren't sent due to the campaign termination. - name: total | type: TotalStatistics | description: Combined statistics of landing page and email distribution. - name: mailsSent | type: integer | description: Total number of emails sent. - name: opened | type: integer | description: Number of landing page views and opened emails. - name: clicked | type: integer | description: Number of landing page and email link clicks. - name: datePublished | type: string | description: Marketing campaign publish date. - name: dateCreated | type: string | description: Date and time when the campaign was created. - name: dateUpdated | type: string | description: Date and time when the campaign was updated. ``` ### Examples ```curl { "entityId": "38d837a5-8303-413c-8ac0-75d735a4bdb0", "actionEvent": { "body": { "campaignId": "c9b491f8-bad0-4d0d-8a1c-c90055d31553", "title": "Email subject", "firstImageUrl": "//static.wixstatic.com/media/eceb8e_e1f32b0d497447a8898e7abcf01d7d87~mv2_d_5600_3733_s_4_2.jpg", "editorType": "WEB", "status": "ACTIVE", "visibilityStatus": "PUBLISHED", "distributionStatus": "DISTRIBUTED", "publishingData": { "landingPageUrl": "https://www.example.com/so/SHORTCODE", "statistics": { "landingPage": {}, "emailCampaign": { "delivered": 2, "opened": 2, "clicked": 2 }, "total": { "mailsSent": 2, "opened": 10, "clicked": 8 } }, "datePublished": "2020-02-14T14:28:54Z" }, "dateCreated": "2020-02-13T11:18:30Z", "dateUpdated": "2020-02-14T14:28:19.680596102Z" } }, "slug": "created", "id": "aacdffe0-8e14-4d1b-8060-8d0bf8248d36", "entityFqdn": "wix.email_marketing.v1.campaign", "eventTime": "2022-09-22T12:58:37.407664Z", "triggeredByAnonymizeRequest": false } ``` --- ## JavaScript SDK ### Schema ``` Webhook: onCampaignCreated Description: Triggered when a campaign is created. Payload: CampaignCreatedEnvelope - name: entity | type: Campaign | description: none - name: campaignId | type: string | description: Campaign GUID. - name: title | type: string | description: Marketing campaign title. If you don't provide the value, the title automatically gets the value of an email subject. - name: firstImageUrl | type: string | description: URL of the first image after the logo. - name: editorType | type: Enum | description: Editor type. - enum: - UNKNOWN: Unknown editor. This value isn't used. - WEB: Classic web editor. - MOBILE: Classic mobile editor. - MJML: Chat (AI) based web editor. - name: status | type: Enum | description: Campaign status. - enum: - UNKNOWN: Unknown campaign. This value isn't used. - ACTIVE: Campaign is active. - ARCHIVED: Campaign is archived. - DELETED: Campaign is deleted. - name: visibilityStatus | type: Enum | description: Campaign visibility status. - enum: - UNKNOWN: Unknown status. This value isn't used. - DRAFT: Campaign isn't published yet. - PUBLISHED: Campaign is published. - TEMPLATE: Campaign is a template. - name: distributionStatus | type: Enum | description: Campaign distribution status. - enum: - UNKNOWN: Unknown distribution status. - NOT_STARTED: Campaign isn't distributed to recipients yet. - SCHEDULED: Campaign is scheduled for distribution. - IN_DETECTION: Campaign is in screening for malicious content. - IN_MODERATION: Campaign is in review by the site moderators. - SAMPLING: Several recipients are selected for campaign testing, and campaign is sent out to them. - SENDING: Campaign is being sent out to all recipients. - REJECTED: Campaign is rejected. - TERMINATED: Campaign is terminated after a failed sampling test. - DISTRIBUTED: Campaign is fully distributed to all recipients. - PAUSED: Scheduled campaign is paused. - name: publishingData | type: PublishingData | description: Publishing data. The field is returned empty if the campaign isn't published. - name: landingPageUrl | type: string | description: Landing page URL. - name: statistics | type: CampaignStatistics | description: Marketing campaign statistics. - name: landingPage | type: LandingPageStatistics | description: Landing page statistics of a marketing campaign. - name: opened | type: integer | description: Number of times when a landing page was loaded or viewed. - name: clicked | type: integer | description: Number of times a link was clicked in a landing page. - name: emailCampaign | type: DistributionStatistics | description: Email distribution statistics of a marketing campaign. - name: delivered | type: integer | description: Number of delivered emails. - name: opened | type: integer | description: Number of recipients who opened an email. If the same recipient opened the same email twice, it is counted as a one unique open. - name: clicked | type: integer | description: Number of recipients who clicked a link in the email. If the same recipient clicked the same link twice, it is counted as a one unique click. If the same recipient clicked different links, it is counted as a one unique click. - name: bounced | type: integer | description: Number of emails that didn't reach the recipient. - name: complained | type: integer | description: Number of recipients who reported the email as a spam. - name: notSent | type: integer | description: Number of emails that weren't sent due to the campaign termination. - name: total | type: TotalStatistics | description: Combined statistics of landing page and email distribution. - name: mailsSent | type: integer | description: Total number of emails sent. - name: opened | type: integer | description: Number of landing page views and opened emails. - name: clicked | type: integer | description: Number of landing page and email link clicks. - name: datePublished | type: Date | description: Marketing campaign publish date. - name: dateCreated | type: Date | description: Date and time when the campaign was created. - name: dateUpdated | type: Date | description: Date and time when the campaign was updated. - name: metadata | type: EventMetadata | description: none - name: instanceId | type: string | description: App instance GUID. - name: eventType | type: string | description: Event type. - name: identity | type: IdentificationData | description: The identification type and identity data. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: identityType | type: WebhookIdentityType | description: - enum: UNKNOWN, ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP - name: accountInfo | type: AccountInfo | description: Details related to the account - name: accountId | type: string | description: GUID of the Wix account associated with the event. - name: parentAccountId | type: string | description: GUID of the parent Wix account. Only included when accountId belongs to a child account. - name: siteId | type: string | description: GUID of the Wix site associated with the event. Only included when the event is tied to a specific site. - name: _id | type: string | description: Event GUID. With this GUID you can easily spot duplicated events and ignore them. - name: entityFqdn | type: string | description: Fully Qualified Domain Name of an entity. This is a unique identifier assigned to the API main business entities. For example, `wix.stores.catalog.product`, `wix.bookings.session`, `wix.payments.transaction`. - name: slug | type: string | description: Event action name, placed at the top level to make it easier for users to dispatch messages. For example: `created`/`updated`/`deleted`/`started`/`completed`/`email_opened`. - name: entityId | type: string | description: GUID of the entity associated with the event. - name: eventTime | type: Date | description: Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example, `2020-04-26T13:57:50.699Z`. - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application (for example, GDPR). - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event. - name: entityEventSequence | type: string | description: A sequence number that indicates the order of updates to an entity. For example, if an entity was updated at 16:00 and then again at 16:01, the second update will always have a higher sequence number. You can use this number to make sure you're handling updates in the right order. Just save the latest sequence number on your end and compare it to the one in each new message. If the new message has an older (lower) number, you can safely ignore it. ``` ### Examples ```javascript import { campaigns } from '@wix/email-marketing'; campaigns.onCampaignCreated((event) => { // handle your event here }); ``` ```javascript import { createClient, AppStrategy } from '@wix/sdk'; import { campaigns } from '@wix/email-marketing'; const wixClient = createClient({ auth: AppStrategy({ appId: 'MY-APP-ID', publicKey: 'YOUR_APP_PUBLIC_KEY', }), modules: { campaigns, }, }); wixClient.campaigns.onCampaignCreated((event) => { // handle your event here }); ``` ---