# Tag integration V1

{% tabs %}
{% tab title="Tag" %}
{% hint style="danger" %}
This API is decrepated, please consider using the [Tag integration V2](https://docs.sirdata.net/ads-api/tag-integration-v2)
{% endhint %}

Add this **tag** to you *header* or directly to the *ad placement* where you would like to access **user segment authorized**

{% hint style="danger" %}
**THIS TAG MAY ACCESS AN EXISTING COOKIE : DO NOT CALL IT UNLESS YOU PREVIOUSLY COLLECTED A VALID CONSENT TO DO SO WHENEVER REQUESTED BY LOCAL LAW**
{% endhint %}

{% hint style="warning" %}
In UE, the UK, Iceland, Liechtenstein and Norway, unless specifically and by written authorized not to, do not call the tag if you didn't previously collected a valid consent for Purposes 1 & 3 and Vendor 53 under the [IAB Europe Transparency & Consent Framework](https://iabeurope.eu/tcf-2-0/), and add the mandatory [***gdpr=\[gdpr\_applies\]\&gdpr\_consent=\[tc\_string\]***](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md) parameters in the URL.
{% endhint %}

Parse the **JSON** result to get the segments you need and push them into your adserver or SSP using key/value pairs.

Use *callback* to use the answer with a predefined javascript function (see *Tag Response* above)

```javascript
function callback(result){
   console.log(result); => callback here
}
var tag = document.createElement('script');
tag.src = 'https://partner-api.sddan.com/api/v1/public/user/partner/[PARTNER_ID]/segment?gdpr=[tcf_v2_gdpr_applies]&gdpr_consent=[tcf_v2_tcstring]&callback=callback';
tag.async = true;
tag.setAttribute('referrerpolicy','unsafe-url');
document.getElementsByTagName('body')[0].appendChild(tag);
```

{% hint style="info" %}
(mandatory) ***\[PARTNER\_ID]*** : *numerical value* - is given by **your contact** at Sirdata during the [API Access](/api-overview/api-access.md) process

(mandatory for EEA/UK users) ***gdpr** :* [TCF V2 *gdpr\_applies* parameter](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20Consent%20string%20and%20vendor%20list%20formats%20v2.md#full-tc-string-passing)

(mandatory for EEA/UK users) ***gdpr\_consent** :* [TCF V2 TC String](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20Consent%20string%20and%20vendor%20list%20formats%20v2.md#full-tc-string-passing)

(optional) *callback :* **callback** function name can be change
{% endhint %}
{% endtab %}

{% tab title="Tag Response" %}
{% hint style="info" %}
Tag response will call the default “callback” with user segments if requested in the call without function name (...*\&callback)*
{% endhint %}

```javascript
callback({"domain": "example.com","partner_id" : 1234,"user_segments" : [{"id":12, "name": "[Sirdata] Fashion"},{"id": 34, "name": "[Sirdata] Woman"}]})
```

{% hint style="info" %}
Tag response will call your **function name** in the resquest (...*\&callback=my\_callback*)
{% endhint %}

```javascript
my_callback({"domain": "example.com","partner_id" : 1234,"user_segments" : [{"id":12, "name": "[Sirdata] Fashion"},{"id": 34, "name": "[Sirdata] Woman"}]})
```

{% hint style="info" %}
**JSON Object Format** if no callback function is requested
{% endhint %}

```javascript
{
  "domain": "example.com",
  "partner_id": 1234,
  "user_segments": [
    {
      "id": 12,
      "name": "[Sirdata] Fashion"
    },
    {
      "id": 34,
      "name": "[Sirdata] Woman"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="danger" %}
**PLEASE REMBER TO HAVE YOUR DOMAIN WHITELISTED, OTHERWIZE THE TAG WILL GET NOW ANSWER**
{% endhint %}


---

# 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.sirdata.net/ads-api/tag.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.
