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. For instance, this allows you to pass keyword IDs from your internal system or other attributes that help you track ad 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. For a request on behalf of an agency, also specify the client login.
- Change keyword parameters
-
curl \ -H 'Authorization: Bearer TOKEN' \ -H 'Client-Login: CLIENT_LOGIN' \ -d '{ "method": "update", "params": { "Keywords": [{ "Id": KEYWORD_1_ID, "UserParam1": "VALUE_1" }, { "Id": KEYWORD_2_ID, "UserParam1": "VALUE_2" }] } }' https://api.direct.yandex.com/json/v5/keywords
- Add a parameter to the ad URL
-
curl \ -H 'Authorization: Bearer TOKEN' \ -H 'Client-Login: CLIENT_LOGIN' \ -d '{ "method": "update", "params": { "Ads": [{ "Id": AD_ID_1, "TextAd": { "Href": "https://www.site.com/1/?utm_source=yandex-direct&utm_term={param1}" } }, { "Id": AD_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 goes to the page https://www.site.com/1/?utm_source=yandex-direct&utm_term=VALUE_1
when the ad is served for keyword 1, and to the page https://www.site.com/1/?utm_source=yandex-direct&utm_term=VALUE_2
when the ad is served for keyword 2.
-d "{\"method\"
...