> For the complete documentation index, see [llms.txt](https://integrations.impact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://integrations.impact.com/integration-guides/for-brands/tracking-integrations/api-online-sale/implementation.md).

# Implementing API (Online Sale)

The exact method in which you implement server-side API calls to impact.com on your site is up to your discretion and specific requirements. This page describes what you'll need to do and keep in mind when implementing.

impact.com strongly recommends implementing an intelligent retry policy for API calls that may fail. Any call that results in a `5XX` response code should be retried automatically, using an [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) strategy, for example, waiting increasing amounts of time between successive attempts, up to a reasonable maximum number of retries (e.g., 5). This avoids overloading impact.com's servers with repeated requests, especially during periods of elevated error rates.

## Capture & Store `im_ref`

* impact.com will dynamically populate an `im_ref` value in your landing page URL (e.g. `https://www.example.com/store/product1?im_ref=1234567`) when visitors are directed to your site from an impact.com tracking link. The query string parameter name is `im_ref`.
* The `im_ref` value should be captured and stored in the browser (e.g., in a first-party cookie) and available if the same visitor returns directly to your site in another session.
* If, during the customer journey, the website URL changes from one domain to another, the stored `im_ref` value should be passed and stored under the new domain.

## Report conversions to the `/Conversions/` endpoint

When a conversion event occurs, you’ll need to make a server-side API call to the `/Conversions/` endpoint with conversion data. When impact.com receives this data, attribution for the conversion is determined and awarded to a partner, making it a new pending action.

{% hint style="success" %}
**Note:** Refer to the [full endpoint documentation](https://integrations.impact.com/brand-api-reference/reference/conversions) to see code examples, parameter definitions, and more.
{% endhint %}

### Example call

In the example below:

* There are two (2) Product Name 1 items being purchased at a unit price of 14.00 each for a SKU set subtotal of 28.00.
* There are three (3) Product Name 2 items being purchased at a unit price of 33.00 each for a SKU set subtotal of 99.00.
* impact.com will take the $15 discount passed and apply that proportionately to all items in the purchase.

A `/Conversions/` call can be customized based on your specific requirements. Refer to the full endpoint documentation to learn about additional parameters.

{% tabs %}
{% tab title="cURL" %}

```bash
curl ‘https://api.impact.com/Advertisers/<AccountSID>/Conversions’ \
  -X POST \
  -u ‘<AccountSID>:<AuthToken>’ \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \ 
  -d ‘CampaignId=1000’ \
  -d ‘EventTypeId=9876’ \
  -d ‘EventDate=2024-08-01T23:55:24-08:00’ \
  -d ‘ClickId=QiiWXOVnrQ3SQHl24jQjyxBGUkmzfJ3i1VHrWM0’ \
  -d ‘CustomerId=BCZ2WVSH674563PDPYOTM3AXDQ’ \
  -d ‘CurrencyCode=USD’ \
  -d ‘OrderId=O1234567’ \
  -d ‘OrderDiscount=15.00’ \
  -d ‘OrderPromoCode=15BUCKSOFF' \
  -d ‘ItemSku1=1ABC2345' \
  -d ‘ItemName1=Product Name 1’ \
  -d ‘ItemCategory1=Hardware’ \
  -d ‘ItemQuantity1=2' \
  -d ‘ItemSubTotal1=28.00’ \
  -d ‘ItemSku2=9ZXY7654’ \
  -d ‘ItemName2=Product Name 2’ \
  -d ‘ItemCategory2=Gardening’ \
  -d ‘ItemQuantity2=3’ \
  -d ‘ItemSubTotal2=99.00’
```

{% endtab %}
{% endtabs %}

Once you have fully integrated the impact.com API, you can begin end-to-end testing to ensure everything is working properly. Learn how to proceed with [End-to-End Testing](/integration-guides/end-to-end-tests.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://integrations.impact.com/integration-guides/for-brands/tracking-integrations/api-online-sale/implementation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
