--- title: "Campaign" slug: "campaign-data-object-php-library-s2s" description: "Track campaigns with the PHP Library: campaign ID, media codes read from the request URL, once-per-session campaigns and campaign parameters." status: "update" updated: 2026-11-02T14:46:18Z published: 2026-11-02T14:46:18Z canonical: "docs.mapp.com/campaign-data-object-php-library-s2s" --- > ## 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 ```php /** * MappIntelligenceCampaign constructor. * @param string $id */ $campaignData = new MappIntelligenceCampaign($id); ``` #### setId ```php /** * @param string $id * @return $this */ $campaignData->setId($id); ``` #### setMediaCode ```php /** * @param array $mediaCode * @return $this */ $campaignData->setMediaCode($mediaCode); ``` #### setOncePerSession ```php /** * @param bool $oncePerSession * @return $this */ $campaignData->setOncePerSession($oncePerSession); ``` #### getId, getMediaCode, isOncePerSession Return the configured values. #### setParameter ```php /** * @param string $id * @param string $value * @return $this */ $campaignData->setParameter($id, $value); ``` **Example** ```php $campaignData = new MappIntelligenceCampaign(); $campaignData    ->setId('wt_mc%3Dfoo.bar.2')    ->setMediaCode(array('wt_mc', 'mc'))    ->setOncePerSession(true)    ->setParameter(1, 'parameter 1')    ->setParameter(2, 'parameter 2'); $mappIntelligence = MappIntelligence::getInstance(); $mappIntelligence->track((new MappIntelligenceDataMap())->campaign($campaignData)); ```