# Custom Shopify Integration

### Integration steps <a href="#integration-steps" id="integration-steps"></a>

### All Pages <a href="#all-pages" id="all-pages"></a>

Embed the tracking script in all pages of your store. **You can find this script in the Settings -> Advanced Settings tab -> Third Party Tracking section**

```
<script type="text/javascript" async defer src="https://api.goaffpro.com/loader.js?shop=goaffprotest1.myshopify.com"></script>
```

You can add the script in the footer page of your site.

### Thank You Page <a href="#thank-you-page" id="thank-you-page"></a>

You should create your thank you page in such a manner that the following variable is exposed in global scope before the tracking script gets loaded

```
Shopify = {    checkout:{        order_id:'SHOPIFY ORDER_ID OF THE ORDER'    }}
```

### Server-Side Integration <a href="#server-side-integration" id="server-side-integration"></a>

Make an HTTP POST call to the following endpoint after the payment is processed to record the sale in the app

```
POST https://api.goaffpro.com/order_completeContent-Type: application/json​{    "ref":"the referral cookie",    "shop":"the shop identifier as found in the tracking script",    "order_id":"the shopify order id"}
```


---

# Agent Instructions: 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:

```
GET https://docs.goaffpro.com/how-tos/manual-integration/custom-shopify-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
