Title: | Load Data from 'MyTarget API v2 and v3' |
---|---|
Description: | Allows work with 'MyTarget Statistics API v2' <https://target.my.com/adv/api-marketing/doc/stat-v2> and 'MyTarget Statistics API v3' <https://target.my.com/adv/api-marketing/doc/stat-v2#statisticsv3> load data by ads, campaigns, agency clients and statistic from your ads account. |
Authors: | Alexey Seleznev [aut, cre] |
Maintainer: | Alexey Seleznev <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.4.0 |
Built: | 2025-02-02 05:11:11 UTC |
Source: | https://github.com/selesnow/rmytarget |
Load data from API 'MyTarget' into R, by agancy clients and campaigns
The DESCRIPTION file:
Package: | rmytarget |
Type: | Package |
Title: | Load Data from 'MyTarget API v2 and v3' |
Version: | 2.4.0 |
Date: | 2021-10-20 |
Authors@R: | c(person(given = "Alexey", family = "Seleznev", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0410-7385")), person(given = "Netpeak", role = c("cph"))) |
Maintainer: | Alexey Seleznev <[email protected]> |
Description: | Allows work with 'MyTarget Statistics API v2' <https://target.my.com/adv/api-marketing/doc/stat-v2> and 'MyTarget Statistics API v3' <https://target.my.com/adv/api-marketing/doc/stat-v2#statisticsv3> load data by ads, campaigns, agency clients and statistic from your ads account. |
URL: | https://selesnow.github.io/rmytarget/ |
Imports: | httr, dplyr, lubridate, stringr, purrr, tidyr |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
Depends: | R (>= 3.5.0) |
License: | MIT + file LICENSE |
Language: | ru |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.2 |
Config/pak/sysreqs: | libicu-dev libssl-dev |
Repository: | https://selesnow.r-universe.dev |
RemoteUrl: | https://github.com/selesnow/rmytarget |
RemoteRef: | HEAD |
RemoteSha: | b9aaec72989575a5cc7339a5181fec97a7cc73ef |
Author: | Alexey Seleznev [aut, cre] (<https://orcid.org/0000-0003-0410-7385>), Netpeak [cph] |
Index of help topics:
myTarAuth Authentication in 'MyTarget API' myTarGetAdList Get ads list from 'MyTarget' myTarGetCampaignList Get campaign list from 'MyTarget' myTarGetClientList Get Agency Clients from 'MyTarget' myTarGetFastStats Returns Basic Statistics in Real Time myTarGetGoalList Get goal list from 'MyTarget' myTarGetGoalsStats Get Goal Statistics from 'MyTarget' myTarGetInAppStats Returns statistics on mobile app events attributed with advertising impressions myTarget by campaigns and banners myTarGetOfflineConversionsStats Returns Statistics on Events Attributed With 'myTarget' Ad Impressions From Offline Conversion Lists for Campaigns myTarGetStats Get stat by clients, campaigns or banners from 'API MyTarget' myTarRefreshToken Refresh Access Token myTarSetLogin Set MyTarget login myTarSetTokenPath Set path to auth cache rmytarget-package Paxkage for load data from 'MyTarget' API.
Alexey Seleznev
1. MyTarget API documents 2. MyTarget API statistic methods 3. Authorization
## Not run: # Get objects ## Get ads Ads <- myTarGetAdList(login = "my_test_client") ## Get campaigns Campaigns <- myTarGetCampaignList(login = "my_test_client") # Get statistic # base metrics by campaigns base_data <- myTarGetTotalData(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = Campaigns$id, metrics = "base", stat_type = "day", login = "my_test_client", token_path = "mytarget_token") # all metrics by campaigns all_data <- myTarGetTotalData(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = Campaigns$id, metrics = "all", stat_type = "day", login = "my_test_client", token_path = "mytarget_token") # custom set of metric by campaigns custom_data <- myTarGetTotalData(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = Campaigns$id, metrics = c("base", "tps", "viral"), stat_type = "day", login = "my_test_client", token_path = "mytarget_token") # if have note objects id, base metrics by ads base_data2 <- myTarGetStats(date_from = as.Date("2013-01-01"), date_to = Sys.Date(), object_type = "banners", metrics = "base", stat_type = "day", login = "my_test_client", token_path = "mytarget_token") ## End(Not run)
## Not run: # Get objects ## Get ads Ads <- myTarGetAdList(login = "my_test_client") ## Get campaigns Campaigns <- myTarGetCampaignList(login = "my_test_client") # Get statistic # base metrics by campaigns base_data <- myTarGetTotalData(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = Campaigns$id, metrics = "base", stat_type = "day", login = "my_test_client", token_path = "mytarget_token") # all metrics by campaigns all_data <- myTarGetTotalData(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = Campaigns$id, metrics = "all", stat_type = "day", login = "my_test_client", token_path = "mytarget_token") # custom set of metric by campaigns custom_data <- myTarGetTotalData(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = Campaigns$id, metrics = c("base", "tps", "viral"), stat_type = "day", login = "my_test_client", token_path = "mytarget_token") # if have note objects id, base metrics by ads base_data2 <- myTarGetStats(date_from = as.Date("2013-01-01"), date_to = Sys.Date(), object_type = "banners", metrics = "base", stat_type = "day", login = "my_test_client", token_path = "mytarget_token") ## End(Not run)
Authentication in 'MyTarget API' by Code Grant Schema or other auth schems. For detail you can see documentation.
myTarAuth( login = getOption("rmytarget.login"), grant_type = "client_credentials", client_id = getOption("rmytarget.client_id"), client_secret = getOption("rmytarget.client_secret"), agency_client_name = NULL, code_grant = getOption("rmytarget.code_grant_auth"), token_path = myTarTokenPath() )
myTarAuth( login = getOption("rmytarget.login"), grant_type = "client_credentials", client_id = getOption("rmytarget.client_id"), client_secret = getOption("rmytarget.client_secret"), agency_client_name = NULL, code_grant = getOption("rmytarget.code_grant_auth"), token_path = myTarTokenPath() )
login |
Account name, used in file name if you save credential |
grant_type |
Your account grant, get one of two values, "client_credentials" or "agency_client_credentials". Not use in Code Grant Schema. |
client_id |
Yoyr client ID. Not use in Code Grant Schema. |
client_secret |
Your client secret. Not use in Code Grant Schema. |
agency_client_name |
Your client user name. Only for "agency_client_credentials" grant_type. |
code_grant |
logical, Use code gran authorise schema, detail |
token_path |
Path to directory where you save credential data. |
No return value, called for side effects
Alexey Seleznev
API authorization documentation by 'MyTarget'.
## Not run: # Recomendation auth by code grant schema myTarAuth(login = "my_account_name") ## End(Not run)
## Not run: # Recomendation auth by code grant schema myTarAuth(login = "my_account_name") ## End(Not run)
Get ads list from 'MyTarget'
myTarGetAdList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath(), request_speed = 1.2 )
myTarGetAdList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath(), request_speed = 1.2 )
auth |
MyTarget Autherization R object. See |
login |
Account name, used in file name if you save credential |
token_path |
Path to directory where you save credential data. |
request_speed |
Integer, or one of slow, normal, fast. Pause between requests to API |
Data frame with banners list
## Not run: myAds <- myTarGetAdList(login = "my_test_client") ## End(Not run)
## Not run: myAds <- myTarGetAdList(login = "my_test_client") ## End(Not run)
Get campaign list from 'MyTarget'
myTarGetCampaignList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath(), request_speed = 1.2 )
myTarGetCampaignList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath(), request_speed = 1.2 )
auth |
MyTarget Autherization R object. See |
login |
Account name, used in file name if you save credential |
token_path |
Path to directory where you save credential data. |
request_speed |
Integer, or one of slow, normal, fast. Pause between requests to API |
Data frame with campaigns list
## Not run: myTargetCampaign <- myTarGetCampaignList(myTargetAuth) ## End(Not run)
## Not run: myTargetCampaign <- myTarGetCampaignList(myTargetAuth) ## End(Not run)
Get Agency Clients from 'MyTarget'
myTarGetClientList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
myTarGetClientList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
auth |
MyTarget Autherization R object. See |
login |
Account name, used in file name if you save credential |
token_path |
Path to directory where you save credential data. |
data frame with agency clients
MyTarget API Documenationhttps://target.my.com/doc/api/detailed/#resource_agency_clients
## Not run: myTarSetLogin("Your Login") clients <- myTarGetClientList() ## End(Not run)
## Not run: myTarSetLogin("Your Login") clients <- myTarGetClientList() ## End(Not run)
returns basic statistics on advertising objects in real time, without taking into account the filtering of incorrect traffic. The summary statistics can vary significantly.
myTarGetFastStats( object_type = "campaigns", object_id = NULL, auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
myTarGetFastStats( object_type = "campaigns", object_id = NULL, auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
object_type |
API object type, character value, apply one of campaigns, banners, users |
object_id |
ID of API object (id campaign or any object) |
auth |
R auth object |
login |
Your login, or client name in MyTarget account |
token_path |
Path to directory where you save credential data |
tibble with fast statistics
## Not run: rt_stat <- myTarGetFastStats() ## End(Not run)
## Not run: rt_stat <- myTarGetFastStats() ## End(Not run)
Get goal list from 'MyTarget'
myTarGetGoalList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
myTarGetGoalList( auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
auth |
MyTarget Autherization R object. See |
login |
Path to directory where you save credential data |
token_path |
Your login, or client name in MyTarget account |
data frame with goals parameters
Get Goal Statistics from 'MyTarget'
myTarGetGoalsStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = NULL, attribution = c("impression", "conversion"), conversion_type = c("postview", "postclick", "total"), auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
myTarGetGoalsStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = NULL, attribution = c("impression", "conversion"), conversion_type = c("postview", "postclick", "total"), auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
date_from |
Start date |
date_to |
End date |
object_type |
API object type, character value, one of campaigns, banners, users. |
object_id |
ID of API object (id campaign or any object). |
attribution |
Attributing by event time or impression time. Available options: conversion, impression, default. |
conversion_type |
Conversion type: postclick - postclick, postview - postview, total - total. |
auth |
MyTarget Autherization R object. See |
login |
Path to directory where you save credential data |
token_path |
Your login, or client name in MyTarget account |
data frame with goal statics
Returns statistics on mobile app events attributed with advertising impressions myTarget by campaigns and banners
myTarGetInAppStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = NULL, attribution = c("conversion", "impression"), conversion_type = c("postview", "postclick", "total"), auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
myTarGetInAppStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = NULL, attribution = c("conversion", "impression"), conversion_type = c("postview", "postclick", "total"), auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
date_from |
Start date |
date_to |
End date |
object_type |
API object type, character value, apply one of campaigns, banners, users |
object_id |
ID of API object (id campaign or any object) |
attribution |
Attributing by event time or impression time. Available options: conversion, impression |
conversion_type |
Conversion type: postclick - postclick, postview - postview, total - total. |
auth |
R auth object |
login |
Your login, or client name in MyTarget account |
token_path |
Path to directory where you save credential data |
tibble with fast statistics
## Not run: rt_stat <- myTarGetFastStats() ## End(Not run)
## Not run: rt_stat <- myTarGetFastStats() ## End(Not run)
Returns Statistics on Events Attributed With 'myTarget' Ad Impressions From Offline Conversion Lists for Campaigns
myTarGetOfflineConversionsStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_id = NULL, auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
myTarGetOfflineConversionsStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_id = NULL, auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath() )
date_from |
Start date |
date_to |
End date |
object_id |
Campaigns IDs |
auth |
R auth object |
login |
Your login, or client name in MyTarget account |
token_path |
Path to directory where you save credential data |
tibble with offline conversions statistics
Get stat by clients, campaigns or banners from 'API MyTarget'
myTarGetStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = NULL, stat_type = "day", metrics = "base", package_id = NULL, attribution = c("conversion", "impression", "default"), banner_status = NULL, campaign_status = NULL, sort_by = NULL, sort_direction = c("asc", "desc"), auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath(), api_version = getOption("rmytarget.stat_api_version") )
myTarGetStats( date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", object_id = NULL, stat_type = "day", metrics = "base", package_id = NULL, attribution = c("conversion", "impression", "default"), banner_status = NULL, campaign_status = NULL, sort_by = NULL, sort_direction = c("asc", "desc"), auth = NULL, login = getOption("rmytarget.login"), token_path = myTarTokenPath(), api_version = getOption("rmytarget.stat_api_version") )
date_from |
Start date |
date_to |
End date |
object_type |
API object type, character value, one of campaigns, banners, users. |
object_id |
ID of API object (id campaign or any object). |
stat_type |
Breakdown by day, possible values: day, summary. |
metrics |
Set of metrics or fields, see metrics section for more ditali, default "base", but you can load any of all, base, events, video, viral, uniques, tps, or go this MyTarget Stat API v2 or MyTarget Stat API v3. |
package_id |
List of package identifiers. Available for banner statistics. |
attribution |
Attributing by event time or impression time. Available options: conversion, impression, default. |
banner_status |
Banner statuses list, available for campaign and banner statistics. Possible values: all, active, blocked, deleted. |
campaign_status |
List of campaign statuses, available for campaign and banner statistics. Possible values: all, active, blocked, deleted. |
sort_by |
The field by which identifiers of campaigns, banners or users will be sorted. Available metrics: base, events, video, viral, carousel, tps, moat, playable, romi. |
sort_direction |
Sorting direction. Available options: asc, desc |
auth |
MyTarget Autherization R object. See |
login |
Path to directory where you save credential data |
token_path |
Your login, or client name in MyTarget account |
api_version |
MyTarget Statistic API version: v2, v3 |
Data frame with statistic.
You can load different sets of metrics, for this use metrics arguments, and set a vector containing the names of the desired metric sets. For more details of v2 API go this link. For more details of v3 API go this link. For example: metrics = c("base", "video", "viral")
base - based metrcis.
Number of impressions
Number of clicks
Number of goals achieved
Cost sum
Average cost per 1000 views
Average cost per click
Average cost per goals
Percentage of clicks to views
Percentage ratio of the number of goals achieved to the number of clicks.
events - metrics for advertised posts on social media feeds.
Number of discoveries of the advertised social networks application
Number of discoveries of the advertised message in the social media feed
Number of transitions to the group page from the advertised message
Number of clicks on the external link in the advertised message
Number of video launches in advertised message
Number of comments left in the advertised message
Number of joining the group through the advertised message
Number of likes of the advertised message
Number of action "Share" for the advertised message.
Number of voting actions in the advertised message
uniques - metrics by the number of unique users.
Number of unique users who saw the ad for the specified period
Number of unique users who saw an ad for all time
Number of new unique users who saw the ad for the specified period
Average frequency of displaying ads to one unique user
video - metrics for video ads.
Number of video playback starts
Number of pauses of video playback
Number of video playback after pause
Number of full-screen video playbacks
Number of shutdowns of full-screen video playback
Number of video mute
Number of video sound starts
Number of views of the first 10 seconds of the video
Number of views of the first 25 percent of the video duration
Number of views of the first 50 percent of the video duration
Number of views of the first 75 of the video duration
Number of views 100 percent of the video duration
Percentage of views with the achievement of the first 10 seconds of the video
Percentage of views with the achievement of the first 25 percent of the video duration
Percentage of views with the achievement of the first 50 percent of the video duration
Percentage of views with the achievement of the first 75 percent of the video duration
Percentage of views with the achievement of the first 100 percent of the video duration
Average video viewing depth (percent)
Average cost of watching the first 10 seconds of a video
Average viewing cost of the first 25 percent of video length
Average viewing cost of the first 50 percent of video length
Average viewing cost of the first 75 percent of video length
Average viewing cost of the first 100 percent of video length
viral - metrics of viral events.
Number of impressions of the shared advertising message in social networks
Number of unique users who saw the shared advertising message for the specified period
Total number of unique users who have seen the shared advertising message for all time
Number of new unique users who saw the shared advertising message for the specified period
Average frequency of displaying a shared advertising message to one unique user
Number of openings of the advertised application from the shared advertising message
Number of discoveries of the shared advertised message in the social media feed
number of transitions to the group page from the shared advertised message
Number of clicks on the external link in the shared advertised message
Number of video launches in the shared advertised message
Number of comments left in the shared advertised message
Number of joining the group through the shared advertised message
Number of likes of the shared advertised message
Number of actions "Share" for the shared advertised message
Number of voting actions in the shared advertised message
carousel - statistics on individual slides of the advertising carousel (N - from 1 to the number of slides).
Number of N slide shows
Number of clicks on slide N
Percentage ratio of clicks to the number of views on slide N
tps - additional write-off statistics.
Additional charges for using the moat service
Additional charges for using third-party data (from dmp).
moat - statistics according to the moat service.
Number of impressions
Number of visible shows
Number of impressions in the inactive tab
Number of impressions out of sight
Additional charges for using third-party data (from dmp).
Number of impressions with visibility duration less than 1 second
Number of verified impressions
number of impressions analyzed
Number of impressions analyzed
Percentage of visible hits
Verified impression percentage
Impression percentage in inactive tab
The percentage of orders with a zone of visibility of the ad is less than 50 percent
Percentage of impressions with visibility duration less than 1 second
Visible impression difference
Average time the ad is in view
Engagement level
playable - Playable Ads metrics.
Opening the game
Closing the game
Clicks
romi - Playable Ads metrics.
The given value of the event
Return on investment
Ad spend share
## Not run: # base metrics by campaigns base_data <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", metrics = "base", stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # all metrics by campaigns all_data <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", metrics = "all", stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # custom set of metric by campaigns custom_data <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", metrics = c("base", "tps", "viral"), stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # if have note objects id, base metrics by ads base_data2 <- myTarGetStats(date_from = as.Date("2013-01-01"), date_to = Sys.Date(), object_type = "banners", metrics = "base", stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # get all stats group by clients, only for agency account client_stat <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "users", metrics = "all", login = "agency_login") ## End(Not run)
## Not run: # base metrics by campaigns base_data <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", metrics = "base", stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # all metrics by campaigns all_data <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", metrics = "all", stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # custom set of metric by campaigns custom_data <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "campaigns", metrics = c("base", "tps", "viral"), stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # if have note objects id, base metrics by ads base_data2 <- myTarGetStats(date_from = as.Date("2013-01-01"), date_to = Sys.Date(), object_type = "banners", metrics = "base", stat_type = "day", login = "client_login", token_path = "D:\\mytarget_token") # get all stats group by clients, only for agency account client_stat <- myTarGetStats(date_from = Sys.Date() - 7, date_to = Sys.Date(), object_type = "users", metrics = "all", login = "agency_login") ## End(Not run)
Refresh Access Token
myTarRefreshToken(old_auth = NULL, client_id = NULL, client_secret = NULL)
myTarRefreshToken(old_auth = NULL, client_id = NULL, client_secret = NULL)
old_auth |
Your old auth object. See |
client_id |
Your client ID |
client_secret |
Your client secret |
No return value, called for side effects
## Not run: auth <- myTarRefreshToken(old_auth = myTargetAuth, client_id = "xxxx", client_secret = "xxxx.") ## End(Not run)
## Not run: auth <- myTarRefreshToken(old_auth = myTargetAuth, client_id = "xxxx", client_secret = "xxxx.") ## End(Not run)
Set MyTarget login
myTarSetLogin(login)
myTarSetLogin(login)
login |
Your login, or client name in MyTarget account |
No return value, called for side effects
Set path to auth cache
myTarSetTokenPath(token_path)
myTarSetTokenPath(token_path)
token_path |
Path to directory where you save credential data |
No return value, called for side effects