--- title: "Campaign" slug: "campaign-1" description: "Track campaigns with the Node.js Library: set a campaign ID or read it from media code URL parameters, track once per session and add campaign parameters." status: "update" updated: 2026-11-02T16:53:00Z published: 2026-11-02T16:53:00Z canonical: "docs.mapp.com/campaign-1" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.mapp.com/llms.txt > Use this file to discover all available pages before exploring further. # Campaign Campaign tracking in Mapp Intelligence enables you to analyze how visitors reach your website, whether through paid advertising, newsletters, or other marketing activities. In a broader sense, campaigns represent all entry sources that bring users to your site. However, this section focuses on campaigns that can be technically tracked, meaning those that include a media code (a specific URL parameter used to identify the campaign source). Typical examples include: - Email newsletters (wt_mc=newsletter.2025.spring) - Google Ads or display banners (mc=display.30off.blue) - Social media promotions or affiliate links (utm_source=facebook&utm_campaign=summer_sale) Before any campaign data can be tracked, a campaign setup must exist in Mapp Q3 under *Configuration > Marketing Configuration*. This setup defines how media codes, ad media, and campaign parameters are structured and recognized in Mapp Intelligence. Without this configuration, no campaign information is collected, even if URLs contain tracking parameters. For more background on campaign concepts, see [Campaign Configuration](/v1/docs/analyses-31-campaign-configuration) in the documentation. --- ## Campaign ID The campaign ID uniquely identifies each campaign tracked in Mapp Intelligence. It consists of the **media code name** and its **value**, separated by "%3D" (URL-encoded =). **Example:** ```plaintext wt_mc%3Dnewsletter.2025.spring ``` This ID format ensures consistent attribution between the tracked visit and the campaign setup in Mapp Intelligence. --- ## Media Code The media code defines the URL parameter used for campaign identification, such as mc, wt_mc, or utm_campaign. Specifying the correct parameter name ensures that campaign entries are correctly attributed to their sources. Without this configuration, campaign tracking accuracy may be reduced, for example if firewalls or browsers remove unknown parameters. This configuration only needs to be implemented on **target or landing pages** that serve as campaign entry points. --- ## Parameters Campaign parameters provide additional details about an advertising medium, such as: - The position of a clicked link within a newsletter - The banner variant in a display campaign - The creative or language version of an ad They can be defined either in the campaign configuration or directly in the page configuration. If the same parameter is defined in both places, the page configuration takes precedence and overwrites the URL parameter. **Example:** ```plaintext www.website.com?wt_mc=Newsletter_2025_10&wt_cc1=link1 ``` --- ## Campaign ID from the Request URL The library determines the campaign ID as follows: 1. An ID set explicitly with the constructor or `setId` is always used. 2. Without an explicit ID, the library reads the campaign from the request URL configured in the library (see Integration and Configuration). For every media code name set with `setMediaCode` (default `mc` and `wt_mc`) that has a value in the URL, `<name>%3D<value>` is added. Several campaign IDs are joined with `;`, for example `?mc=abc&wt_mc=def` becomes `mc%3Dabc;wt_mc%3Ddef`. 3. If neither yields an ID, no campaign ID is sent. The library reads only the media codes from the request URL. Campaign parameters in the URL (such as `wt_cc1`) are not read; transmit them with `setParameter`. --- ## Once per Session With `setOncePerSession`, a campaign is transmitted only once per session: - The library reads the campaigns already transmitted from the cookie `wtstp_tcc` of the incoming request. The request cookies must be available to the library (see Integration and Configuration). - The check works per campaign: campaigns already transmitted are removed from the ID, new ones are sent and remembered. If no new campaign remains, the campaign ID `ignore%3Dignore` is sent instead. - This also applies to an ID set explicitly with `setId`. Return the updated cookie to the browser: `getTransmittedCampaignsCookie` returns it after a new campaign was transmitted. Add it to your HTTP response, otherwise once per session cannot work across requests (see Classes). --- **Supported Methods** | **Method** | **Description** | **Where to configure *** | **Where to analyze** | | --- | --- | --- | --- | | **constructor** | Initializes a campaign object. The campaign ID can be set via setId. | – | *Marketing > Campaigns > Advertising Media* | | **setId** | Defines the campaign ID in the format mediaCodeName%3DmediaCodeValue (URL-encoded =), e.g. wt_mc%3Dnewsletter.2025.spring. | – | *Marketing > Campaigns > Advertising Media* | | **setMediaCode** | Defines the URL parameters (media codes) from which the campaign ID is read when no ID is set explicitly, e.g. `?mc=abc`. Default: `mc` and `wt_mc`. An explicitly set ID always wins. | – | *Marketing > Campaigns > Advertising Media* | | **setOncePerSession** | Tracks a campaign only once per session: a campaign that was already transmitted in this session is not sent again. | – | *Marketing > Campaigns > Advertising Media* | | **setParameter** | Tracks additional campaign-specific information that always refers to an advertising medium. | CP > Own Configuration | – | * **Configuration Path Abbreviations:** - **CP** = *Mapp Q3 > Configuration > Custom Parameters > Campaign Parameters > Preconfigured > …* #### Generated request parameters | **Method** | **Request parameter** | **Constant** | | --- | --- | --- | | **constructor** / **setId** / **setMediaCode** / **setOncePerSession** | `mc` (resolved campaign ID) | `CAMPAIGN_ID` | | – | `mca` (always `c`, set automatically) | `CAMPAIGN_ACTION` | | **setParameter** | `cc<ID>` | `CUSTOM_CAMPAIGN_PARAMETER` | > [!NOTE] > Note > > Values that are empty or exactly `0`, `0.0`, `false` or `{}` are not transmitted. For example, a campaign parameter with the value `0` or `false` is not sent. To transmit such a value, send the request with a parameter map (see Request Parameters). **Methods** constructor ```javascript const mappCampaignData = new MappIntelligenceCampaign(); ``` ```javascript /** * @param i A campaign ID consists of a media code name and its value, separated by "%3D" */ const mappCampaignData = new MappIntelligenceCampaign(i: string); ``` setId ```javascript /** * @param i A campaign ID consists of a media code name and its value, separated by "%3D" * * @return MappIntelligenceCampaign */ mappCampaignData.setId(i: string); ``` setMediaCode Without an explicit ID (constructor or `setId`), the campaign is read from these parameters of the request URL (see `setRequestURL` in [Configuration](/v1/docs/nodejs-integration-and-configuration)), the same way the client-side pixel does: `?mc=abc&wt_mc=def` becomes the campaign ID `mc%3Dabc;wt_mc%3Ddef`. An explicitly set ID always wins. ```javascript /** * @param mc Names of the URL parameters that carry the campaign ID (default: ["mc", "wt_mc"]) * * @return MappIntelligenceCampaign */ mappCampaignData.setMediaCode(mc: Array); ``` setOncePerSession A campaign that was already transmitted in this session is not sent again; if no new campaign is left, `ignore%3Dignore` is sent. The transmitted campaigns are kept in the cookie `wtstp_tcc`: pass the request cookies with `setCookie()` and add the cookie of `getTransmittedCampaignsCookie()` to the HTTP response (see [Classes](/v1/docs/nodejs-classes)), otherwise it only works within one tracking instance. ```javascript /** * @param ops A campaign ID is tracked only once per session * * @return MappIntelligenceCampaign */ mappCampaignData.setOncePerSession(ops: boolean); ``` getId / getMediaCode / isOncePerSession ```javascript mappCampaignData.getId();            // explicitly set campaign ID, empty if it is read from the request URL mappCampaignData.getMediaCode();     // names of the URL parameters mappCampaignData.isOncePerSession(); // boolean ``` setParameter ```javascript /** * Campaign parameters always refer to an advertising medium. * * @param i    ID of the parameter * @param value Value of the parameter * * @return MappIntelligenceCampaign */ mappCampaignData.setParameter(i: number, value: string); ``` **Example** ```javascript const mic = new MappIntelligenceConfig( "111111111111111", "analytics01.wt-eu02.net" ); const mit = new MappIntelligenceTracking(mic); const mappCampaignData = new MappIntelligenceCampaign(); mappCampaignData.setId("wt_mc%3Dfoo.bar.2")    .setParameter(1, "parameter 1")    .setParameter(2, "parameter 2"); await mit.track((new MappIntelligenceDataMap()).campaign(mappCampaignData)); await mit.close(); ``` #### Example: once per session, read from the request URL ```javascript app.get('/landing', async function(request, response) {    const mic = new MappIntelligenceConfig("111111111111111", "analytics01.wt-eu02.net")        .setRequestURL('https://' + request.headers['host'] + request.url)        .setCookie(request.cookies);    const mit = new MappIntelligenceTracking(mic);    await mit.track((new MappIntelligenceDataMap()).campaign(new MappIntelligenceCampaign().setOncePerSession(true)));    const campaignCookie = mit.getTransmittedCampaignsCookie();    if (campaignCookie) {        // a session cookie: no maxAge        response.cookie(campaignCookie.getName(), campaignCookie.getValue(), {            path: campaignCookie.getPath(),            secure: campaignCookie.isSecure(),            httpOnly: campaignCookie.isHttpOnly()        });    }    await mit.close();    response.send('...'); }); ``` > [!NOTE] > Note > > The value round trip works with the default encoding of Express and `cookie-parser`: Express encodes the value once more, `cookie-parser` decodes it, and `setCookie()` decodes it again.