---
title: "Save campaign piggyback"
type: reference
method: POST
path: /rest-api/piggyback/campaign/save.do
tag: "Piggybacks"
---

# Save campaign piggyback

`POST https://YOUR-NETWORK-DOMAIN/rest-api/piggyback/campaign/save.do`

Creates a new piggyback tracking pixel and attaches it to the specified campaign, or with 'id' edits that existing piggyback of the campaign. The piggyback can be of type BEACON (HTML tracking code snippet) or URL (redirect URL), specified via the model attribute. You can target a specific action by providing actionId, or set allActions to true to apply to all actions. Optionally scope the piggyback to a specific site or placement within the campaign. The caller must have update permissions on the campaign and the Piggyback Pixel Tracking permission. Returns a JSON object with a 'success' boolean and validation errors if any.

## Form params

| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| `campaignId` | integer | yes | `2001` | The unique numeric identifier of the campaign to attach the new piggyback tracking pixel to |
| `actionId` | integer | no | `101` | Conditionally required — when allActions is false; ignored when it is true. The unique numeric identifier of the action to attach the piggyback to |
| `allActions` | boolean | no | `true` | When true, the piggyback is applied to all actions of the campaign, making actionId unnecessary |
| `siteId` | integer | no | `3001` | Optional site ID to scope this piggyback to a specific site within the campaign |
| `placementId` | integer | no | `4001` | Optional placement ID to scope this piggyback to a specific placement within the campaign |
| `id` | integer | no | `701` | ID of an existing piggyback of this campaign to edit instead of creating a new one; one that is not the campaign's answers 400 |
| `active` | boolean | no | `true` | Whether this piggyback is active |
| `codeUrl` | string | no | `https://tracker.example.com/pixel?cid=123` | Piggyback URL or HTML/JavaScript code |
| `deliveryAttribution` | string | no | `ALL` | Which conversions this piggyback fires for: ALL, POST_CLICK_ONLY or POST_VIEW_ONLY |
| `sampling` | integer | no | `100` | Sampling rate percentage (0-100) controlling how often the piggyback fires |
| `type` | string | no | `URL` | Piggyback type: URL (a URL fired as a pixel) or BEACON (an HTML/JavaScript snippet) |

## Responses

- `200` — Campaign piggyback saved successfully
- `400` — An invalid field (per-field errors); nothing is saved
- `401` — Unauthorized - authentication error
- `403` — Forbidden - no rights on the campaign, or the Piggyback Pixel Tracking permission is not enabled
- `404` — Campaign, site or placement not found or deleted
- `500` — Internal server error

## Example request

```bash
curl --request POST \
  --url 'https://YOUR-NETWORK-DOMAIN/rest-api/piggyback/campaign/save.do' \
  --header 'X-Api-Key: YOUR_API_KEY' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'campaignId=2001' \
  --data-urlencode 'siteId=3001' \
  --data-urlencode 'id=701' \
  --data-urlencode 'type=URL' \
  --data-urlencode 'active=true' \
  --data-urlencode 'actionId=101'
```

Source: https://epom.com/ad-server/docs/api/piggybacks/post-piggyback-campaign-save