| get_report | R Documentation |
Retrieves YouTube Analytics reports containing YouTube Analytics data.
get_report(
ids,
metrics,
start_date = NULL,
end_date = NULL,
currency = NULL,
dimensions = NULL,
filters = NULL,
include_historical_channel_data = NULL,
max_results = NULL,
sort = NULL,
start_index = NULL,
...
)
ids |
String. Channel or content owner identifier.
For channels: |
metrics |
String. Comma-separated list of YouTube Analytics metrics,
such as |
start_date |
String. Start date for the report. Can be in YYYY-MM-DD format or relative date like "last_30_days", "this_month", "yesterday". |
end_date |
String. End date for the report. Can be in YYYY-MM-DD format or relative date. If NULL and start_date is relative, will be calculated automatically. |
currency |
Optional. String. Default is USD. Specifies what earnings
metrics like |
dimensions |
String. Optional. Comma-separated list of YouTube Analytics
dimensions, such as |
filters |
String. Optional. Dimension value filters. Multiple filters
can be separated by semicolons. For video filtering:
|
include_historical_channel_data |
Boolean. Default is FALSE. “Whether the API response should include channels' watch time and view data from the time period prior to when the channels were linked to the content owner.” |
max_results |
Integer. Optional. The maximum number of rows to include in the response. |
sort |
String. Optional A comma-separated list of dimensions or metrics that determine the sort order for YouTube |
start_index |
Integer. Optional. “The 1-based index of the first entity to retrieve.” |
... |
Additional arguments passed to |
named list
If you encounter a 404 "Not Found" error, check the following:
Ensure YouTube Analytics API is enabled in your Google Cloud Console project
Verify your authentication token is valid and has the correct scopes
Check that the channel ID (if using specific channel ID) exists and you have access to it
Use "channel==MINE" to access your own authenticated channel's
data
https://developers.google.com/youtube/analytics/reference/reports/query
## Not run:
# Basic channel report
get_report(ids = "channel==MINE", metrics = "views",
start_date = "2020-01-01", end_date = "2020-01-31")
# Report with video filtering (requires dimensions = "video")
get_report(ids = "channel==MINE",
metrics = "views,likes,comments",
dimensions = "video",
filters = "video==videoId1,videoId2",
start_date = "2020-01-01", end_date = "2020-01-31")
# Report with country filtering
get_report(ids = "channel==MINE",
metrics = "views",
filters = "country==US",
start_date = "2020-01-01", end_date = "2020-01-31")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.