Learn R Programming

rvkstat (version 3.2.0)

vkGetAdAgeStats: Statistics on Audience Coverage by Age.

Description

Returns statistics on the reach of advertising campaigns and ads by age.

Usage

vkGetAdAgeStats(
    account_id   = getOption("rvkstat.account_id"),
    ids_type     = "campaign",
    ids,
    period       = c("day", "month", "overall"),
    date_from    = Sys.Date() - 30,
    date_to      = Sys.Date(),
    username     = getOption("rvkstat.username"),
    api_version  = getOption("rvkstat.api_version"),
    token_path   = vkTokenPath(),
    access_token = getOption("rvkstat.access_token")
)

Arguments

account_id

The ID of the advertising account, a list of all available advertising offices can be obtained using the function vkGetAdAccounts.

ids_type

The type of objects requested that are listed in the ids parameter. Valid values "ad" - are ads, "campaigns" - are campaigns.

ids

Vector id of the requested ads, campaigns, clients or account, depending on what is specified in the ids_type parameter.

period

The way data is grouped by date is day-by-day statistics, month is month-by-month statistics, overall is all-time statistics. Time limits are specified in the date_from and date_to arguments.

date_from

The start date of the displayed statistics in the format YYYY-MM-DD.

date_to

End date of the displayed statistics in the format YYYY-MM-DD.

username

Your vkontakte login.

api_version

Vkontakte API version.

token_path

Path to dir with credentials

access_token

API access tokens obtained using vkAuth or vkGetToken functions

Value

Date frame with community statistics with the following values:

id

id of the object from the ids argument.

day

(if the period is equal to day) day in the format YYYY-MM-DD.

month

(if period is equal to month) - day in the format YYYY-MM.

day_from

(if period is overall) the start date of the reporting period.

day_to

(if period is overall) end date of the reporting period.

type

object type from the ids_type parameter.

age

age.

impressions_rate

part of the audience that viewed the ad, from 0 to 1.

clicks_rate

(the part of the audience that clicked on the ad, from 0 to 1.

References

Documentation for API method ads.getDemographics: https://vk.com/dev/ads.getDemographics

Examples

Run this code
# NOT RUN {
## auth
my_tok <- vkAuth(app_id = 1, app_secret = "H2Pk8htyFD8024mZaPHm")

# 1.Get a static message on audience coverage by sex, 
# advertising campaigns in the context of days
## 1.1. We get a list of advertising campaigns
camp <- vkGetAdCampaigns(account_id = 1)
                         
## 1.2. We get statistics on advertising campaigns
vk_ad_age_stat_day <- vkGetAdAgeStats(account_id = 1,
                                      ids_type = "campaign",
                                      ids = camp$id ,
                                      period = "day",
                                      date_from = "2010-01-01", 
                                      date_to = "2017-09-10")
										
										
# 2.Receive a static message on the ads in the context of months
## 2.1. We get a list of advertising campaigns
ads <- vkGetAds(account_id = account_id)

## 2.2. Get ad statistics
vk_ad_age_stat_month <- vkGetAdAgeStats(account_id = 1,
                                        ids_type = "ad",
                                        ids = ads$id ,
                                        period = "month",
                                        date_from = "2010-01-01", 
                                        date_to = "2017-09-10")
			
			
# 3.Get a static message on reaching the audience for advertising campaigns 
# without a temporary breakdown
## 3.1. We get a list of advertising campaigns
camp <- vkGetAdCampaigns(account_id = 1)

## 3.2. We get statistics on advertising campaigns
vk_ad_age_stat_total <- vkGetAdAgeStats(account_id = 1,
                                        ids_type = "campaign",
                                        ids = camp$id ,
                                        period = "overall",
                                        date_from = "2010-01-01", 
                                        date_to = "2017-09-10")

# }

Run the code above in your browser using DataLab