# Branch for Advocate — Technical Reference

Your Advocate program can integrate with [Branch Metrics](http://branch.io/).

This technical reference explains the specific fields, features, API calls and functionality that is used in the integration. Just getting started? Learn how to [Integrate with Branch for Advocate Programs](https://dash.readme.com/project/impact-brand/v11.0/docs/branch-metrics-integration).

### Link handling behaviors

After the Branch integration is configured, link-handling behaviors will change.

* Referral links (e.g., `ssqt.co/h126b21`) will begin redirecting to Branch links
* Advocate will [create branch links](https://help.branch.io/using-branch/docs/creating-a-deep-link) dynamically and set values for `data`, `channel`, `tags`, and `desktop_URL`.
* Branch deep link `data` will include details of the referral code, advocate, and reward. See the field reference below for an example.
* Analytics tags will be added to help you track the performance of different platforms.
  * `channel`: The referral medium. Value can be 1 of: `FACEBOOK`, `TWITTER`, `EMAIL`, `DIRECT`, `REMINDER`, or `UNKNOWN`.
  * `tags`: The source of the referral. Value may be 1 of: `STANDARD`, `MOBILE`, or `UNKNOWN`.

impact.com will send all link clicks through Branch, but will continue to redirect desktop traffic to your program’s landing page. This is done by setting the Branch value for `desktop_url`. If you set a desktop url for your app in Branch, it will be overwritten.

### Field reference <a href="#field-reference" id="field-reference"></a>

When impact.com creates links dynamically in Branch, we include a number of metadata fields in the data field. These include fields from the User, Referral Code and Reward objects.

| Field             | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ----------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sq_id`           | string | The customer advocate's user ID. This allows you to look up the user in your own system.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `sq_accountId`    | string | The customer advocate's account ID. This allows you to look up group or company info.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `sq_firstName`    | string | The customer advocate's first name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `sq_lastName`     | string | The customer advocate's last name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `sq_imageUrl`     | string | The customer advocate's profile image URL. Note that unlike the user's imageUrl that is used other places in Advocate, if this field is set to null it won't actually be null. Instead, when set to null it is replaced by an gravatar link that is automatically generated based on a hash for the customer advocate's email address. If you want to detect for null images instead, you should look for its gravatar, or not use this field and look up the value in your user database.                                                                                                                                                   |
| `sq_referralCode` | string | The customer advocate's referral code. This is necessary to attribute the referral.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `sq_amount`       | string | <p>The amount of the referred friend's reward. We map this abstract field to other rewards fields that can be looked up via the API or UTT.</p><ul><li>For rewards of type <code>TIME\_CREDIT</code> and <code>CREDIT</code>, this field is equal to the reward field called <code>credit</code></li><li>For rewards of type <code>PCT\_DISCOUNT</code>, this field is equal to the reward field called <code>discountPercent</code></li><li>For rewards of type <code>FEATURE</code>, this field is equal to the reward field called <code>quantity</code></li><li>For rewards of type <code>GIFTCODE</code>, this field is empty</li></ul> |
| `sq_unit`         | string | The unit of the referred friend's reward. For example, in a 10% off referral program, this would be `PERCENT`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `sq_type`         | string | The type of the referred friend's reward. One of: `PCT_DISCOUNT`, `TIME_CREDIT`, `FEATURE`, `CREDIT`, `GIFTCODE`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

### Example deep link

When impact.com creates a link dynamically in Branch, the resulting deep link will include analytics tags, redirects, and custom metadata. Here’s an example.

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

```json
{
  "code": "BRITTANYTEST",
  "$desktop_url": "http://landingpage.com/a/test_a6whcgrt0vcw3/widgets/referral?code=BRITTANYTEST&referralMedium=DIRECT&referralSource=STANDARD",
  "sq_accountId": "55a43496ebbaff9cf86443d3",
  "sq_amount": "10",
  "sq_firstName": "Brittany",
  "sq_id": "55a43496ebbaf01cebac42cb",
  "sq_imageUrl": "http://gravatar.com/avatar/77af7eba41d1ccad2bf2c13704637c25?d=mm",
  "sq_lastName": "Test",
  "sq_referralCode": "BRITTANYTEST",
  "sq_type": "PCT_DISCOUNT",
  "sq_unit": "PERCENT",
  "~channel": "DIRECT",
  "~tags": ["STANDARD"],
  "~creation_source": "API",
  "+is_first_session": false,
  "+clicked_branch_link": true
}
```

{% endtab %}
{% endtabs %}


---

# 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://integrations.impact.com/integration-guides/for-brands/advocate/mobile-options-for-advocate/branch-metrics-for-advocate/branch-for-advocate-technical-reference.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.
