# Campaign Manager (v1)

Information note **Campaign Manager is supported by the Singer community**   
This integration is powered by [Singer's](https://www.singer.io/) Campaign Manager tap. For support, [visit the GitHub repo](https://github.com/singer-io/tap-doubleclick-campaign-manager) or [join the Singer Slack](https://singer-slackin.herokuapp.com/).

## Campaign Manager integration summary

Stitch’s Campaign Manager integration replicates data using the [Campaign Manager 360 API](https://developers.google.com/doubleclick-advertisers/getting_started) . Refer to the [Schema](https://help.qlik.com/en-US/stitch/integrations/saas/campaign-manager#schema) section for a list of objects available for replication.

## Campaign Manager feature snapshot

A high-level look at Stitch's Campaign Manager (v1) integration, including release status, useful links, and the features supported in Stitch.

| **STITCH** |  |  |  |
| --- | --- | --- | --- |
| **[Release status](https://help.qlik.com/en-US/stitch/integrations/identify-an-integration-version)** | Released on August 17, 2018 | **Supported by**<br><br>the Info icon<br><br>Indicates if the integration is supported by Stitch or the Singer community. | [Singer Community](https://www.singer.io/) |
| **Stitch plan**<br><br>the Info icon<br><br>The type of Stitch plan required to use the integration. | Standard | **[API availability](https://help.qlik.com/en-US/stitch/developers/stitch-connect/guides/source-destination-reference)**<br><br>the Info icon<br><br>Indicates if the integration is available as a source in Stitch Connect. | the Success icon<br><br>This version of the integration is available via the API.<br><br><br>Available |
| **Singer GitHub repository** | [singer-io/tap-doubleclick-campaign-manager](https://github.com/singer-io/tap-doubleclick-campaign-manager) |  |  |
| **REPLICATION SETTINGS** |  |  |  |
| **[Anchor Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/anchor-scheduling)**<br><br>the Info icon<br><br>A type of replication scheduling where an integration's Replication Frequency is anchored to a time you select. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported | **[Advanced Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/advanced-scheduling)**<br><br>the Info icon<br><br>A type of replication scheduling that allows you to specify granular start times for data extraction using cron expressions. | the Remove icon<br><br>Advanced Scheduling is not supported for this integration.<br><br><br>Unsupported |
| **Table-level reset**<br><br>the Info icon<br><br>Indicates if data can be reset at the table level. If unsupported, data can only be reset at the integration level. | the Remove icon<br><br>Table-level resets are not supported for this integration. Resets are only supported at the integration level.<br><br><br>Unsupported | **[Configurable Replication Methods](https://help.qlik.com/en-US/stitch/replication/replication-methods)**<br><br>the Info icon<br><br>Indicates if Replication Methods can be defined by you for tables in the integration. | the Remove icon<br><br>Configurable Replication Methods are not supported for this integration. Stitch will use pre-defined replication methods for tables you set to replicate.<br><br><br>Unsupported |
| **DATA SELECTION** |  |  |  |
| **Table selection**<br><br>the Info icon<br><br>The ability to select individual tables for replication in the Stitch interface. If table selection is unavailable, all tables and all the columns they contain will be set to replicate by default. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported | **Column selection**<br><br>the Info icon<br><br>The ability to select individual columns for replication in the Stitch interface. If column selection is unavailable, all columns will be set to replicate by default. | the Remove icon<br><br>Column selection is not supported for this integration. All available columns in tables set to replicate will be selected.<br><br><br>Unsupported |
| **Select all**<br><br>the Info icon<br><br>Indicates if the integration supports selecting all available tables and columns. | the Success icon<br><br>Supported<br><br><br>Supported |  |  |
| **TRANSPARENCY** |  |  |  |
| **[Extraction Logs](https://help.qlik.com/en-US/stitch/replication/extractions/integration-extraction-logs)**<br><br>the Info icon<br><br>Logs detailing the Extraction phase of the replication process for a given integration. Includes error info, should an error occur. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported | **[Loading Reports](https://help.qlik.com/en-US/stitch/replication/integration-loading-reports)**<br><br>the Info icon<br><br>Reports detailing the Loading phase of the replication process for a given integration. Includes the number of rows loaded for each table and error info, should an error occur. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported |

## Connecting Campaign Manager

### Campaign Manager setup requirements

To set up Campaign Manager in Stitch, you need:

* **A Campaign Manager account**. Refer to [Google’s website](https://www.google.com/doubleclick/advertisers/) for signup information.

* **API access.** Most accounts have this enabled by default. If you’re not sure, contact your representative or the [support team](mailto:%20dcm-support@google.com).

* **Access to the reports you want to replicate.** Stitch will only be able to replicate the reports that the user who authorizes the integration has access to.

### Step 1: Verify report access

Before you connect Campaign Manager to Stitch, you should verify that you have access to the reports you want to replicate. Stitch will only be able to replicate data for the same reports that you have access to in Campaign Manager.

1. [Sign into your Campaign Manager account and navigate to the **Report Builder** page](https://www.google.com/analytics/dfa/).

2. Under **Reports**, click **My Reports**.

3. A list of all the reports you have access to will display:

   ![List of reports in Campaign Manager](https://help.qlik.com/en-US/stitch/images/integrations/doubleclick-campaign-manager-all-reports.png)List of reports in Campaign ManagerList of reports in Campaign Manager

4. Verify that the reports you want to replicate are listed on this page.

### Step 2: Locate your Campaign Manager profile ID

Information note **Need to connect multiple profiles?** To connect more than one Campaign Manager profile, you’ll need to create additional Campaign Manager integrations in your Stitch account.

![](https://help.qlik.com/en-US/stitch/images/integrations/doubleclick-campaign-manager-profile-id.png)

1. [Sign into your Campaign Manager account](https://www.google.com/dfa/trafficking).

2. Click the user menu (your icon) in the top right corner.

3. In the dropdown beneath the **Sign out** button will be a list of the profiles you have access to.

4. Locate the ID of the profile you want to connect. This will be a seven digit number next to the name of the profile. For example: `9999999`

   An example is highlighted in the image to the right.

5. Copy the profile ID.

Keep this handy - you’ll need it in the next step.

### Step 3: Add Campaign Manager as a Stitch data source

1. [Sign into your Stitch account](https://app.stitchdata.com/).

2. On the Stitch Dashboard page, click the **Add Integration** button.

3. Click the **Campaign Manager** icon.

4. Enter a name for the integration. This is the name that will display on the Stitch Dashboard for the integration; it’ll also be used to create the schema in your destination.

   For example, the name “Stitch Campaign Manager” would create a schema called `stitch_campaign_manager` in the destination. **Note**: Schema names cannot be changed after you save the integration.

5. In the **Profile ID** field, paste the ID of the Campaign Manager profile from [Step 2](https://help.qlik.com/en-US/stitch/integrations/saas/campaign-manager#locate-your-profile-id). This value should be a seven digit number such as `9999999`.

### Step 4: Create a replication schedule

Information note Replication schedules affect the time Extraction begins, not the time to data loaded. Refer to the [Replication Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling) documentation for more information.

In the **Replication Frequency** section, you’ll create the integration’s [replication schedule](https://help.qlik.com/en-US/stitch/replication/replication-scheduling). An integration’s replication schedule determines how often Stitch runs a replication job, and the time that job begins.

Campaign Manager integrations support the following replication scheduling methods:

* [Replication Frequency](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/replication-frequency)

* [Anchor Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/anchor-scheduling)

To keep your row usage low, consider setting the integration to replicate less frequently. See the [Understanding and Reducing Your Row Usage guide](https://help.qlik.com/en-US/stitch/getting-started/understanding-stitch-usage) for tips on reducing your usage.

### Step 5: Authorize Stitch to access Campaign Manager

1. If you aren’t already signed into your Google account, you’ll be prompted for your credentials.
2. After you sign in, you’ll see a list of the permissions requested by Stitch:
   * **View and manage DoubleClick for Advertisers reports** - This is required to allow Stitch to view and run reports. **Note**: Stitch will not alter report settings, and will only ever read data. Refer to the [Replication section](https://help.qlik.com/en-US/stitch/integrations/saas/campaign-manager#replication) below for more info.
3. To grant access, click the **Allow** button.
4. After you’ve granted access, you’ll be redirected back to Stitch to finish setting up the integration.

### Step 6: Set objects to replicate

Information note **Is an object missing or not replicating?** Verify that the object meets the requirements for [selection](https://help.qlik.com/en-US/stitch/replication/extractions/data-selection/setting-tables-and-columns-to-replicate#selection-requirements) and [replication](https://help.qlik.com/en-US/stitch/replication/extractions/data-selection/setting-tables-and-columns-to-replicate#replication-requirements).

The last step is to select the tables you want to replicate. [Learn about the available tables for this integration.](https://help.qlik.com/en-US/stitch/integrations/saas/campaign-manager#schema)

**Note**: If a replication job is currently in progress, new selections won’t be used until the next job starts.

* Selection options
* Individual tables
* All tables

For Campaign Manager integrations, you can select:

1. **Individual tables**

2. **All tables**

Click the tabs to view instructions for each selection method.

1. In the integration’s **Tables to Replicate tab**, locate a table you want to replicate.

2. To track a table, click the **checkbox** next to the table’s name. A blue checkmark means the table is set to replicate.

3. Repeat this process for all the tables you want to replicate.

4. When finished, click the **Finalize Your Selections** button at the bottom of the screen to save your selections.

Information note **Important**: Using the **Select All** feature will overwrite any previous selections. However, selections aren’t final until **Finalize Your Selections** is clicked. Clicking **Cancel** will restore your previous selections. Refer to the [Select All guide](https://help.qlik.com/en-US/stitch/replication/extractions/data-selection/setting-tables-and-columns-to-replicate#set-all-data-to-replicate) for more info about this feature.

1. Click into the integration from the Stitch Dashboard page.

2. Click the **Tables to Replicate** tab.

3. In the list of tables, click the box next to the **Table Names** column.

4. In the menu that displays, click **Track all Tables and Fields**:

   ![The Track all Tables and Fields menu in the Tables to Replicate tab](https://help.qlik.com/en-US/stitch/images/replication/select-all-tables-menu.png)The Track all Tables and Fields menu in the Tables to Replicate tabThe Track all Tables and Fields menu in the Tables to Replicate tab

5. Click the **Finalize Your Selections** button at the bottom of the page to save your data selections.

### Initial and historical replication jobs

After you finish setting up Campaign Manager, its **Sync Status** may show as **Pending** on either the Stitch Dashboard or in the Integration Details page.

For a new integration, a **Pending** status indicates that Stitch is in the process of scheduling the initial replication job for the integration. **This may take some time to complete.**

Information note

**Initial replication jobs with Anchor Scheduling**

If using Anchor Scheduling, an initial replication job may not kick off immediately. This depends on the selected Replication Frequency and Anchor Time. Refer to the [Anchor Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling#job-scheduling-and-anchor-times) documentation for more information.

#### Free historical data loads

The first seven days of replication, beginning when data is first replicated, are free. Rows replicated from the new integration during this time won’t count towards your quota. Stitch offers this as a way of testing new integrations, measuring usage, and ensuring historical data volumes don’t quickly consume your quota.

Information note **Replication will continue after the seven days are over**. If you’re no longer interested in this source, be sure to **pause** or **delete** the integration to prevent unwanted usage.

## Campaign Manager replication

When Stitch replicates data from Campaign Manager, the process will look like this:

1. Stitch runs the selected report using the report’s defined date range and included dimensions and metrics.
2. Campaign Manager creates a CSV file of the report results.
3. Stitch replicates the results from the CSV.

Each run of a report will have its own CSV file in Campaign Manager, which you can access by [signing into your Campaign Manager account](https://www.google.com/dfa/trafficking).

#### Report date ranges

When Stitch replicates data for a given report, it will use the date range currently defined in Campaign Manager for that report.

For example: The image below shows the configuration for a report named `ad_performance_report`, where the date range is set to the last 30 days. When Stitch replicates data for this report, it will run the report using these settings:

![Report date range field highlighted in Campaign Manager](https://help.qlik.com/en-US/stitch/images/integrations/doubleclick-campaign-manager-report-settings.png)Report date range field highlighted in Campaign ManagerReport date range field highlighted in Campaign Manager

### Data loading and Append-Only Replication

When Stitch loads the extracted data into your destination, it will do so using Append-Only Replication. This is a type of Incremental Replication where existing rows aren’t updated, but appended to the end of the table.

Additionally, the number of rows loaded into the table during each replication job is dependent on the combination of unique values in the dimension columns you track. See the [Column Selection and Statistic Aggregation section](https://help.qlik.com/en-US/stitch/integrations/saas/campaign-manager#column-selection-statistic-aggregation) for more info and examples.

##### Example

Let’s say these columns are tracking in the `ad_performance_report` table:

* `date` (dimension) - The date pertaining to the record.

* `campaignId` (dimension) - This is the ID associated with a campaign. In this example, there are two campaigns: `929007494` and `929599581`

* `device` (dimension) - The device type. There are two values for this example: `Computer` and `Tablet`

* `impressions` (metric) - The total number of impressions.

Every time Stitch replicates and loads data, a row for each unique combination of the dimension columns will be appended to the end of the table:

| \_sdc\_report\_datetime | date |  | campaignId | device | impressions |
| --- | --- | --- | --- | --- | --- |
| 2017-10-01 17:48:26.791 | 2017-09-10 00:00:00 |  | 929007494 | Computer | 61 |
| 2017-10-01 17:48:26.791 | 2017-09-10 00:00:00 |  | 929007494 | Tablet | 15 |
| 2017-10-01 17:48:26.791 | 2017-09-10 00:00:00 |  | 929599581 | Computer | 37 |
| 2017-10-01 17:48:26.791 | 2017-09-10 00:00:00 |  | 929599581 | Tablet | 9 |

#### Query for the latest data

Information note

**You may need to alter this query**

The query below is meant to act as a foundation for writing your own. Depending on your SQL syntax and the dimensions contained in a given table, you may need to alter this query for your own usage.

When querying your Campaign Manager data, you’ll want to include the Dimensions you’re analyzing in the partition. For example: If you’re analyzing campaigns over time, you’d include columns like `campaignId` and `date`.

If you want only the most recently replicated data for any Campaign Manager table, you can use the sample query below to account for the Append-Only Replication Stitch uses.

This query will use the report’s Dimensions and the `_sdc_report_datetime` column to return the latest data:

```
SELECT *
  FROM (
        SELECT *,
        RANK() OVER (PARTITION BY dimension_1, dimension_2, etc., 
                     ORDER BY _sdc_report_datetime DESC)
        FROM ad_performance_report
        ORDER BY dimension_1, dimension_2, etc. ASC
       ) AS latest
 WHERE latest.rank = 1
```

In this query:

1. [A subquery first uses a window function](https://chartio.com/resources/tutorials/using-window-functions/) to create a ‘window’ of data for each combination of Dimensions,
2. The values of the `_sdc_report_datetime` column are ranked within each window partition, and
3. Then, in the outer query, only the rows with `_sdc_report_datetime` values ranked as `1` - which is equal to the maximum timestamp - are returned.

## Campaign Manager table reference

Information note

**Schemas and versioning**

Schemas and naming conventions can change from version to version, so we recommend verifying your integration’s version before continuing.

The schema and info displayed below is for **version 1** of this integration.

This is the latest version of the Campaign Manager integration.

Information note

**Table and column names in your destination**

Depending on your destination, table and column names may not appear as they are outlined below.

For example: Object names are lowercased in Redshift (`CusTomERs` &gt; `customers`), while case is maintained in PostgreSQL destinations (`CusTomERs` &gt; `CusTomERs`). Refer to the [Loading Guide](https://help.qlik.com/en-US/stitch/replication/loading/destination-guides) for your destination for more info.