Add tags to an ad URL
Uses the cURL utility.
This example shows how to append custom tags to an ad URL. The tag values are specified in the UserParam1 parameter for keywords using the Keywords.update method. The tag is appended to the ad URL using the Ads.update method. You can use this method to pass data such as keyword IDs from your internal system or other attributes for tracking campaign performance.
To use the examples, change the input data to specify the OAuth token and the IDs of ads and keywords, and edit the URL. If you're submitting a request on behalf of an agency, be sure to include the client's login.
Change keyword parameters
curl \
-H 'Authorization: Bearer ТОКЕН' \
-H 'Client-Login: ЛОГИН_КЛИЕНТА' \
-d '{ "method": "update",
"params": {
"Keywords": [{
"Id": ИДЕНТИФИКАТОР_ФРАЗЫ_1,
"UserParam1": "ЗНАЧЕНИЕ_1"
},
{
"Id": ИДЕНТИФИКАТОР_ФРАЗЫ_2,
"UserParam1": "ЗНАЧЕНИЕ_2"
}]
}
}' https://api.direct.yandex.com/json/v5/keywords
Add a parameter to the ad URL
curl \
-H 'Authorization: Bearer ТОКЕН' \
-H 'Client-Login: ЛОГИН_КЛИЕНТА' \
-d '{ "method": "update",
"params": {
"Ads": [{
"Id": ИДЕНТИФИКАТОР_ОБЪЯВЛЕНИЯ_1,
"TextAd": {
"Href": "https://www.site.com/1/?utm_source=yandex-direct&utm_term={param1}"
}
},
{
"Id": ИДЕНТИФИКАТОР_ОБЪЯВЛЕНИЯ_2,
"TextAd": {
"Href": "https://www.site.com/2/?utm_source=yandex-direct&utm_term={param1}"
}
}]
}
}' https://api.direct.yandex.com/json/v5/ads
Result: The first link in the ad leads to https://www.site.com/1/?utm_source=yandex-direct&utm_term=VALUE_1 when the ad is served for keyword 1, and to https://www.site.com/1/?utm_source=yandex-direct&utm_term=VALUE_2 when the ad is served for keyword 2.
Note
For cURL in Windows, replace all single quotes with double quotes, and escape double quotes in JSON code. For example: -d "{\"method\"...