YouTube Analytics Data Model

Connection String Options

  1. Auto Cache
  2. Cache Connection
  3. Cache Driver
  4. Cache Location
  5. Cache Metadata
  6. Cache Query Result
  7. Callback URL
  8. Channel Id
  9. Connect On Open
  10. Content Owner Id
  11. Default Filter
  12. Firewall Password
  13. Firewall Port
  14. Firewall Server
  15. Firewall Type
  16. Firewall User
  17. Initiate OAuth
  18. Location
  19. Logfile
  20. Max Log File Size
  21. OAuth Access Token
  22. OAuth Client Id
  23. OAuth Client Secret
  24. OAuth JWT Cert
  25. OAuth JWT Cert Password
  26. OAuth JWT Cert Subject
  27. OAuth JWT Cert Type
  28. OAuth JWT Issuer
  29. OAuth JWT Subject
  30. OAuth Refresh Token
  31. OAuth Settings Location
  32. Offline
  33. Other
  34. Pool Idle Timeout
  35. Pool Max Size
  36. Pool Wait Time
  37. Proxy Auth Scheme
  38. Proxy Auto Detect
  39. Proxy Password
  40. Proxy Port
  41. Proxy Server
  42. Proxy SSL Type
  43. Proxy User
  44. Pseudo Columns
  45. Readonly
  46. RTK
  47. SSL Server Cert
  48. Tables
  49. Timeout
  50. Use Connection Pooling
  51. Verbosity
  52. Views

Auto Cache

Data Type

bool

Default Value

false

Remarks

When AutoCache is set, the driver automatically maintains a cache of your table's data in the database of your choice. With CacheQueryResult set, the driver updates the cache when you execute a SELECT query and returns the live results from the YouTube Analytics data.

 

Explicitly Caching SELECT Results

 

CacheQueryResult is a way to query YouTube Analytics in real time while maintaining a cache for offline use. Set CacheQueryResult to update the cache whenever you execute a SELECT statement. When you execute a SELECT statement with AutoCache and CacheQueryResult set, the driver executes the query to the remote data and caches the results; rows that already exist are overwritten. That is, SELECT statements are used to create and refresh the cache, not to query it. Data manipulation commands are executed to the remote data as well.

To query the cached data, set the Offline property. If you need to query the cached data in an online connection, you can append #CACHE to the table name. For example:

SELECT * FROM [Groups#CACHE]

 

 

Setting the Caching Database

 

When AutoCache is set, the driver caches to a simple, file-based cache. You can configure its location or cache to a different database with the following properties:

 

 

See Also

 

 

  • CacheQueryResult: Insert or update each row returned into the corresponding table in the cache.
  • Caching: Best Practices: This section provides more examples of using AutoCache with Offline, as well as information on determining a caching strategy.

    When this property is set, the driver builds a temporary, in-memory dataset that caches the results of the queries you execute. Result sets for subsequent queries are extracted from this dataset, if possible.

    This property is useful in BI, analytics, and other tools that generate queries for you. In these tools, explicit cache queries with the #CACHE syntax may not be an option.

  • CacheMetadata: This property reduces the amount of metadata that crosses the network by persisting table schemas retrieved from the YouTube Analytics metadata. Metadata then needs to be retrieved only once instead of every connection.
  • CACHE Statements: You can use the CACHE statement to persist any SELECT query, as well as manage the cache; for example, refreshing schemas.

 

 

 

Cache Connection

Data Type

string

Default Value

""

Remarks

The cache database is determined based on the CacheDriver and CacheConnection properties. Both properies are required to use the cache database. Examples of common cache database settings can be found below. For more information on setting the caching database's driver, refer to CacheDriver.

The connection string specified in the CacheConnection property is passed directly to the underlying CacheDriver. Consult the documentation for the specific JDBC driver for more information on the available properties. Make sure to include the JDBC driver in your application's classpath.

 

Derby and Java DB

 

The driver simplifies caching to Derby, only requiring you to set the CacheLocation property to make a basic connection.

Alternatively, you can configure the connection to Derby manually using CacheProvider and CacheConnection. Below is the Derby JDBC URL syntax:

jdbc:derby:[subsubprotocol:][databaseName][;attribute=value[;attribute=value] ... ]
For example, to cache to an in-memory database, use the following:
jdbc:derby:memory

 

 

SQLite

 

To cache to SQLite, you can use the SQLite JDBC driver. Below is the syntax of the JDBC URL:

jdbc:sqlite:dataSource
  • Data Source: The path to an SQLite database file. Or, use a value of :memory to cache in memory.

 

 

MySQL

 

The installation includes the CData JDBC Driver for MySQL. Below is an example JDBC URL:

jdbc:mysql:User=root;Password=root;Server=localhost;Port=3306;Database=cache
Below are typical connection properties:

 

 

  • Server: The IP address or domain name of the server you want to connect to.
  • Port: The port that the server is running on.
  • User: The username provided for authentication to the database.
  • Password: The password provided for authentication to the database.
  • Database: The name of the database.
SQL Server

 

The JDBC URL for the Microsoft JDBC Driver for SQL Server has the following syntax:

jdbc:sqlserver://[serverName[\instance][:port]][;database=databaseName][;property=value[;property=value] ... ]
For example:
jdbc:sqlserver://localhost\sqlexpress:1433;integratedSecurity=true
Below are typical SQL Server connection properties:
  • Server: The name or network address of the computer running SQL Server. To connect to a named instance instead of the default instance, this property can be used to specify the host name and the instance, separated by a backslash.
  • Port: The port SQL Server is running on.
  • Database: The name of the SQL Server database.
  • Integrated Security: Set this option to true to use the current Windows account for authentication. Set this option to false if you are setting the User and Password in the connection.

    To use integrated security, you will also need to add sqljdbc_auth.dll to a folder on the Windows system path. This file is located in the auth subfolder of the Microsoft JDBC Driver for SQL Server installation. The bitness of the assembly must match the bitness of your JVM.

  • User: The username provided for authentication with SQL Server. Only needed if you are not using integrated security.
  • Password: The password provided for authentication with SQL Server. Only needed if you are not using integrated security.
Oracle

 

Below is the conventional JDBC URL syntax for the Oracle JDBC Thin driver:

jdbc:oracle:thin:[userId/password]@[//]host[[:port][:sid]]
For example:
jdbc:oracle:thin:scott/tiger@myhost:1521:orcl
Below are typical connection properties:
  • Data Source: The connect descriptor that identifies the Oracle database. This can be a TNS connect descriptor, an Oracle Net Services name that resolves to a connect descriptor, or, after version 11g, an Easy Connect naming (the host name of the Oracle server with an optional port and service name).

  • Password: The password provided for authentication with the Oracle database.
  • User Id: The user Id provided for authentication with the Oracle database.
PostgreSQL

 

Below is the JDBC URL syntax for the official PostgreSQL JDBC driver:

jdbc:postgresql:[//[host[:port]]/]database[[?option=value][[&option=value][&option=value] ... ]]
For example, the following connection string connects to a database on the default host (localhost) and port (5432):
jdbc:postgresql:postgres
Below are typical connection properties:
  • Host: The address of the server hosting the PostgreSQL database.
  • Port: The port used to connect to the server hosting the PostgreSQL database.
  • Database: The name of the database.
  • Username: The user Id provided for authentication with the PostgreSQL database. You can specify this in the JDBC URL with the "user" parameter.
  • Password: The password provided for authentication with the PostgreSQL database.

 

 

Cache Driver

Data Type

string

Default Value

""

Remarks

You can cache to any database for which you have a JDBC driver, including CData JDBC drivers.

The cache database is determined based on the CacheDriver and CacheConnection properties. The CacheDriver is the name of the JDBC driver class that you would like to use to cache data.

Note that you must also add the CacheDriver JAR to the classpath.

The following examples show how to cache to several major databases. Refer to CacheConnection for more information on the JDBC URL syntax and typical connection properties.

Derby and Java DB

 

 

The driver simplifies Derby configuration. Java DB is the Oracle distribution of Derby. The JAR is shipped in the JDK. You can find the JAR, derby.jar, in the db subfolder of the JDK installation. In most caching scenarios, you need to specify only the following, after adding derby.jar to the classpath.

jdbc:youtubeanalytics:CacheLocation='c:/Temp/cachedir';InitiateOAuth=GETANDREFRESH;ContentOwnerId=MyContentOwnerId;ChannelId=ChannelId;
To customize the Derby JDBC URL, use CacheDriver and CacheConnection. For example, to cache to an in-memory database, use a JDBC URL like the following:
jdbc:youtubeanalytics:CacheDriver=org.apache.derby.jdbc.EmbeddedDriver;CacheConnection='jdbc:derby:memory';InitiateOAuth=GETANDREFRESH;ContentOwnerId=MyContentOwnerId;ChannelId=ChannelId;
SQLite

 

Below is a JDBC URL for the SQLite JDBC driver:

jdbc:youtubeanalytics:CacheDriver=org.sqlite.JDBC;CacheConnection='jdbc:sqlite:C:/Temp/sqlite.db';InitiateOAuth=GETANDREFRESH;ContentOwnerId=MyContentOwnerId;ChannelId=ChannelId;
MySQL

 

Below is a JDBC URL for the included CData JDBC Driver for MySQL:

jdbc:youtubeanalytics:Cache Driver=cdata.jdbc.mysql.MySQLDriver;Cache Connection='jdbc:mysql:Server=localhost;Port=3306;Database=cache;User=root;Password=123456';InitiateOAuth=GETANDREFRESH;ContentOwnerId=MyContentOwnerId;ChannelId=ChannelId;
The CData JDBC Driver for MySQL is located in the lib subfolder of the CData JDBC Driver for YouTube Analytics 2017 installation directory.
SQL Server

 

The following JDBC URL uses the Microsoft JDBC Driver for SQL Server:

jdbc:youtubeanalytics:Cache Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver;Cache Connection='jdbc:sqlserver://localhost\sqlexpress:7437;user=sa;password=123456;databaseName=Cache';InitiateOAuth=GETANDREFRESH;ContentOwnerId=MyContentOwnerId;ChannelId=ChannelId;
Oracle

 

Below is a JDBC URL for the Oracle Thin Client:

jdbc:youtubeanalytics:Cache Driver=oracle.jdbc.driver.OracleDriver;CacheConnection='jdbc:oracle:thin:scott/tiger@localhost:1521:orcldb';InitiateOAuth=GETANDREFRESH;ContentOwnerId=MyContentOwnerId;ChannelId=ChannelId;
PostgreSQL

 

The following JDBC URL uses the official PostgreSQL JDBC driver:

jdbc:youtubeanalytics:CacheDriver=org.postgresql.Driver;CacheConnection='jdbc:postgresql://localhost:5433/postgres?user=postgres&password=admin';InitiateOAuth=GETANDREFRESH;ContentOwnerId=MyContentOwnerId;ChannelId=ChannelId;

 

 

Cache Location

Data Type

string

Default Value

""

Remarks

The CacheLocation is a simple, file-based cache. The driver uses Java DB, Oracle's distribution of the Derby database. To cache to Java DB, you will need to add the Java DB JAR to the classpath. The JAR, derby.jar, is shipped in the JDK and located in the db subfolder of the JDK installation.

CacheLocation defaults to the directory specified by the Location setting.

See Also

 

 

  • AutoCache: Set this to implicitly create and maintain a cache for later offline use.
  • CacheMetadata: Set this to persist the YouTube Analytics catalog in CacheLocation.

 

 

Cache Metadata

Data Type

bool

Default Value

false

Remarks

As you execute queries with this property set, table metadata in the YouTube Analytics catalog are cached to the file store specified by CacheLocation if set or the user's home directory otherwise. A table's metadata will be retrieved only once, when the table is queried for the first time.

When to Use CacheMetadata

 

The driver automatically persists metadata in memory for up to two hours when you first discover the metadata for a table or view and therefore, CacheMetadata is generally not required. CacheMetadata becomes useful when metadata operations are expensive such as when you are working with large amounts of metadata or when you have many short-lived connections.

When Not to Use CacheMetadata

 

 

  • When you are working with volatile metadata: Metadata for a table is only retrieved the first time the connection to the table is made. To pick up new, changed, or deleted columns, you would need to delete and rebuild the metadata cache. Therefore, it is best to rely on the in-memory caching for cases where metdata will change often.
  • When you are caching to a database: CacheMetadata can only be used with CacheLocation. If you are caching to another database with the CacheDriver and CacheConnection properties, use AutoCache to cache implicitly. Or, use CACHE Statements to cache explicitly.

 

 

Cache Query Result

Data Type

bool

Default Value

false

Remarks

When CacheQueryResult and AutoCache are set, the rows returned from a SELECT query are cached in the cache database. The driver handles caching in a streaming fashion with each row being processed into the cache database from the original result set as you read the row from the returned ResultSet object. This ensures that the live data is not queried twice. Note that any rows you do not read from the returned ResultSet will not be updated in the cache.

 

Callback URL

Data Type

string

Default Value

""

Remarks

This value is the URL that YouTube Analytics redirects to during the authentication process.

 

Channel Id

Data Type

string

Default Value

""

Remarks

The Id of a channel belonging to the authenticated user. You can find this on the advanced account settings page for your channel. If not specified, MINE will be used; this returns data for the authenticated user's YouTube channel.

 

Connect On Open

Data Type

bool

Default Value

false

Remarks

When set to 'true', a connection will be made to YouTube Analytics when the connection is opened. This property enables the 'Test Connection' feature available in various database tools.

This feature acts as a NOOP command as it is used to verify a connection can be made to YouTube Analytics and nothing from this initial connection is maintained.

Setting this property to 'false' may provide performance improvements (depending upon the number of times a connection is opened).

 

Content Owner Id

Data Type

string

Default Value

""

Remarks

The Id of the copyright holder for content in YouTube's rights management system. The content owner is the person or organization that claims videos and sets their monetization policy.

 

Default Filter

Data Type

string

Default Value

"EndDate=Today"

Remarks

A default filter to be applied to all queries. Convenient for setting default Dimensions, StartDate, EndDate, and Segments for all queries. These values will be overridden if set in the query. Example value: Dimensions=Year AND EndDate=Today

 

 

Firewall Password

Data Type

string

Default Value

""

Remarks

This property is passed to the proxy specified by FirewallServer and FirewallPort, following the authentication method specified by FirewallType.

 

Firewall Port

Data Type

string

Default Value

""

Remarks

This specifies the TCP port for a proxy allowing traversal of a firewall. Use FirewallServer to specify the name or IP address. Specify the protocol with FirewallType.

 

Firewall Server

Data Type

string

Default Value

""

Remarks

This property specifies the IP address, DNS name, or host name of a proxy allowing traversal of a firewall. The protocol is specified by FirewallType: Use FirewallServer with this property to connect through SOCKS or do tunneling. Use ProxyServer to connect to an HTTP proxy.

Note that the driver uses the system proxy by default. To use a different proxy, set ProxyAutoDetect to false.

 

Firewall Type

Data Type

string

Default Value

"NONE"

Remarks

This property specifies the protocol that the driver will use to tunnel traffic through the FirewallServer proxy. Note that by default the driver connects to the system proxy; to disable this behavior and connect to one of the following proxy types, set ProxyAutoDetect to false.

 

   
Type Default Port Description
TUNNEL 80 When this is set, the driver opens a connection to YouTube Analytics and traffic flows back and forth through the proxy.
SOCKS4 1080 When this is set, the driver sends data through the SOCKS 4 proxy specified by FirewallServer and FirewallPort and passes the FirewallUser value to the proxy, which determines if the connection request should be granted.
SOCKS5 1080 When this is set, the driver sends data through the SOCKS 5 proxy specified by FirewallServer and FirewallPort. If your proxy requires authentication, set FirewallUser and FirewallPassword to credentials the proxy recognizes.

 

To connect to HTTP proxies, use ProxyServer and ProxyPort. To authenticate to HTTP proxies, use ProxyAuthScheme, ProxyUser, and ProxyPassword.

 

 

Firewall User

Data Type

string

Default Value

""

Remarks

The FirewallUser and FirewallPassword properties are used to authenticate against the proxy specified in FirewallServer and FirewallPort, following the authentication type specified in FirewallType.

 

Initiate OAuth

Data Type

string

Default Value

"OFF"

Remarks

The following options are available:

  1. OFF: Indicates that the OAuth flow will be handled entirely by the user. An OAuthAccessToken will be required to authenticate.
  2. GETANDREFRESH: Indicates that the entire OAuth Flow will be handled by the driver. If no token currently exists, it will be obtained by prompting the user via the browser. If a token exists, it will be refreshed when applicable.
  3. REFRESH: Indicates that the driver will only handle refreshing the OAuthAccessToken. The user will never be prompted by the driver to authenticate via the browser. The user must handle obtaining the OAuthAccessToken and OAuthRefreshToken initially.

 

 

Location

Data Type

string

Default Value

""

Remarks

The path to a directory which contains the schema files for the driver (.rsd files for tables and views, .rsb files for stored procedures). The Location property is only needed if you would like to customize definitions (e.g., change a column name, ignore a column, etc.) or extend the data model with new tables, views, or stored procedures.

The schema files used in your application must be deployed with other assemblies. You must also ensure that Location points to the folder that contains the schema files. The folder location can be a relative path from the location of the executable.

 

Logfile

Data Type

string

Default Value

""

Remarks

For more control over what is written to the log file, take a look at Verbosity.

 

Max Log File Size

Data Type

string

Default Value

""

Remarks

A string specifying the maximum size in bytes for a log file (ex: 10MB). When the limit is hit, a new log is created in the same folder with the date and time appended to the end. There is no limit by default. Values lower than 100kB will use 100kB as the value instead.

 

OAuth Access Token

Data Type

string

Default Value

""

Remarks

The OAuthAccessToken property is used to connect using OAuth. The OAuthAccessToken is retrieved from the OAuth server as part of the authentication process. It has a server-dependent timeout and can be reused between requests.

The access token is used in place of your username and password. The access token protects your credentials by keeping them on the server.

 

OAuth Client Id

Data Type

string

Default Value

""

Remarks

OAuth requires you to register your application. As part of the registration, you will receive a client Id, sometimes also called a consumer key, and a client secret. You must specify both the OAuthClientId and OAuthClientSecret to connect to an OAuth server.

 

OAuth Client Secret

Data Type

string

Default Value

""

Remarks

OAuth requires you to register your application. As part of the registration you will receive a client Id and a client secret, sometimes also called a consumer secret. You must specify both the OAuthClientId and OAuthClientSecret to connect to an OAuth server.

 

OAuth JWT Cert

Data Type

string

Default Value

""

Remarks

The name of the certificate store for the client certificate.

The OAuthJWTCertType field specifies the type of the certificate store specified by OAuthJWTCert. If the store is password protected, specify the password in OAuthJWTCertPassword.

OAuthJWTCert is used in conjunction with the OAuthJWTCertSubject field in order to specify client certificates. If OAuthJWTCert has a value, and OAuthJWTCertSubject is set, a search for a certificate is initiated. Please refer to the OAuthJWTCertSubject field for details.

Designations of certificate stores are platform-dependent.

The following are designations of the most common User and Machine certificate stores in Windows:

 

 

   
MY A certificate store holding personal certificates with their associated private keys.
CA Certifying authority certificates.
ROOT Root certificates.
SPC Software publisher certificates.

 

In Java, the certificate store normally is a file containing certificates and optional private keys.

When the certificate store type is PFXFile, this property must be set to the name of the file. When the type is PFXBlob, the property must be set to the binary contents of a PFX file (i.e. PKCS12 certificate store).

 

OAuth JWT Cert Password

Data Type

string

Default Value

""

Remarks

If the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.

 

OAuth JWT Cert Subject

Data Type

string

Default Value

"*"

Remarks

When loading a certificate the subject is used to locate the certificate in the store.

If an exact match is not found, the store is searched for subjects containing the value of the property.

If a match is still not found, the property is set to an empty string, and no certificate is selected.

The special value "*" picks the first certificate in the certificate store.

The certificate subject is a comma separated list of distinguished name fields and values. For instance "CN=www.server.com, OU=test, C=US, E=support@cdata.com". Common fields and their meanings are displayed below.

 

   
Field Meaning
CN Common Name. This is commonly a host name like www.server.com.
O Organization
OU Organizational Unit
L Locality
S State
C Country
E Email Address

 

If a field value contains a comma it must be quoted.

 

OAuth JWT Cert Type

Data Type

string

Default Value

""

Remarks

This property can take one of the following values:

 

   
USER - default For Windows, this specifies that the certificate store is a certificate store owned by the current user. Note: This store type is not available in Java.
MACHINE For Windows, this specifies that the certificate store is a machine store. Note: this store type is not available in Java.
PFXFILE The certificate store is the name of a PFX (PKCS12) file containing certificates.
PFXBLOB The certificate store is a string (base-64-encoded) representing a certificate store in PFX (PKCS12) format.
JKSFILE The certificate store is the name of a Java key store (JKS) file containing certificates. Note: this store type is only available in Java.
JKSBLOB The certificate store is a string (base-64-encoded) representing a certificate store in Java key store (JKS) format. Note: this store type is only available in Java.
PEMKEY_FILE The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate.
PEMKEY_BLOB The certificate store is a string (base64-encoded) that contains a private key and an optional certificate.
PUBLIC_KEY_FILE The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate.
PUBLIC_KEY_BLOB The certificate store is a string (base-64-encoded) that contains a PEM- or DER-encoded public key certificate.
SSHPUBLIC_KEY_FILE The certificate store is the name of a file that contains an SSH-style public key.
SSHPUBLIC_KEY_BLOB The certificate store is a string (base-64-encoded) that contains an SSH-style public key.
P7BFILE The certificate store is the name of a PKCS7 file containing certificates.
PPKFILE The certificate store is the name of a file that contains a PPK (PuTTY Private Key).
XMLFILE The certificate store is the name of a file that contains a certificate in XML format.
XMLBLOB The certificate store is a string that contains a certificate in XML format.

 

 

OAuth JWT Issuer

Data Type

string

Default Value

""

Remarks

The issuer of the Java Web Token. This is typically either the Client ID or Email Address of the OAuth Application.

 

OAuth JWT Subject

Data Type

string

Default Value

""

Remarks

The user subject for which the application is requesting delegated access. Typically, the user account name or email address.

 

OAuth Refresh Token

Data Type

string

Default Value

""

Remarks

The OAuthRefreshToken property is used to refresh the OAuthAccessToken when using OAuth authentication.

 

OAuth Settings Location

Data Type

string

Default Value

"%APPDATA%\\CData\\YouTubeAnalytics Data Provider\\OAuthSettings.txt"

Remarks

When InitiateOAuth is set to GETANDREFRESH or REFRESH, the driver saves OAuth values to a settings file to avoid requiring the user to manually enter OAuth connection properties. The default OAuthSettingsLocation is a settings file located in the %AppData%\CData folder.

 

Offline

Data Type

bool

Default Value

false

Remarks

When Offline is set to TRUE, all queries execute against the cache as opposed to the live data source. In this mode, certain queries like INSERT, UPDATE, DELETE, and CACHE are not allowed.

 

Other

Data Type

string

Default Value

""

Remarks

The Other property is a semicolon-separated list of name-value pairs used in connection parameters specific to a data source.

Caching Configuration

 

   
CachePartial=True Caches only a subset of columns, which you can specify in your query.
QueryPassthrough=True Passes the specified query to the cache database instead of using the SQL parser of the driver.

 

Integration and Formatting

 

   
ConvertDateTimeToGMT Whether to convert date-time values to GMT, instead of the local time of the machine.
RecordToFile=filename Records the underlying socket data transfer to the specified file.
ClientCulture This property can be used to specify the format of data (e.g., currency values) that is accepted by the client application. This property can be used when the client application does not support the machine's culture settings. For example, Microsoft Access requires 'en-US'.
Culture This setting can be used to specify culture settings that determine how the driver interprets certain data types that are passed into the driver. For example, setting Culture='de-DE' will output German formats even on an American machine.

 

 

Pool Idle Timeout

Data Type

string

Default Value

""

Remarks

The allowed idle time from when the connection is free to when the connection is released and returned to the pool. The default is 60 seconds.

 

Pool Max Size

Data Type

string

Default Value

"100"

Remarks

The maximum connections in the pool. The default is 100. To disable this property, set the property value to 0 or less.

 

Pool Wait Time

Data Type

string

Default Value

""

Remarks

The max seconds to wait for a connection to become available. If a new connection request is waiting for an available connection and exceeds this time, an error is thrown. By default, new requests wait forever for an available connection.

 

Proxy Auth Scheme

Data Type

string

Default Value

"BASIC"

Remarks

This value specifies the authentication type to use to authenticate to the HTTP proxy specified by ProxyServer and ProxyPort.

Note that the driver will use the system proxy settings by default, without further configuration needed; if you want to connect to another proxy, you will need to set ProxyAutoDetect to false, in addition to ProxyServer and ProxyPort. To authenticate, set ProxyAuthScheme and set ProxyUser and ProxyPassword, if needed.

The authentication type can be one of the following:

  • BASIC: The driver performs HTTP BASIC authentication.
  • DIGEST: The driver performs HTTP DIGEST authentication.
  • NEGOTIATE: The driver retrieves an NTLM or Kerberos token based on the applicable protocol for authentication.
  • PROPRIETARY: The driver does not generate an NTLM or Kerberos token. You must supply this token in the Authorization header of the HTTP request.
If you need to use another authentication type, such as SOCKS 5 authentication, see FirewallType.

 

 

Proxy Auto Detect

Data Type

bool

Default Value

true

Remarks

By default, the driver uses the system HTTP proxy. Set this to false if you want to connect to another proxy.

To connect to an HTTP proxy, see ProxyServer.

For other proxies, such as SOCKS or tunneling, see FirewallType.

 

Proxy Password

Data Type

string

Default Value

""

Remarks

This property is used to authenticate to an HTTP proxy server that supports NTLM (Windows), Kerberos, or HTTP authentication. To specify the HTTP proxy, you can set ProxyServer and ProxyPort. To specify the authentication type, set ProxyAuthScheme.

If you are using HTTP authentication, additionally set ProxyUser and ProxyPassword to HTTP proxy.

If you are using NTLM authentication, set ProxyUser and ProxyPassword to your Windows password. You may also need these to complete Kerberos authentication.

For SOCKS 5 authentication or tunneling, see FirewallType.

By default, the driver uses the system proxy. If you want to connect to another proxy, set ProxyAutoDetect to false.

 

Proxy Port

Data Type

string

Default Value

"80"

Remarks

The port the HTTP proxy is running on that you want to redirect HTTP traffic through. Specify the HTTP proxy in ProxyServer. For other proxy types, see FirewallType.

 

Proxy Server

Data Type

string

Default Value

""

Remarks

The hostname or IP address of a proxy to route HTTP traffic through. The driver can use the HTTP, Windows (NTLM), or Kerberos authentication types to authenticate to an HTTP proxy.

If you need to connect through a SOCKS proxy or tunnel the connection, see FirewallType.

By default, the driver uses the system proxy. If you need to use another proxy, set ProxyAutoDetect to false.

 

Proxy SSL Type

Data Type

string

Default Value

"AUTO"

Remarks

This property determines when to use SSL for the connection to an HTTP proxy specified by ProxyServer. This value can be AUTO, ALWAYS, NEVER, or TUNNEL. The applicable values are the following:

 

   
AUTO Default setting. If the URL is an HTTPS URL, the driver will use the TUNNEL option. If the URL is an HTTP URL, the component will use the NEVER option.
ALWAYS The connection is always SSL enabled.
NEVER The connection is not SSL enabled.
TUNNEL The connection is through a tunneling proxy: The proxy server opens a connection to the remote host and traffic flows back and forth through the proxy.

 

 

Proxy User

Data Type

string

Default Value

""

Remarks

The ProxyUser and ProxyPassword options are used to connect and authenticate against the HTTP proxy specified in ProxyServer.

You can select one of the available authentication types in ProxyAuthScheme. If you are using HTTP authentication, set this to the username of a user recognized by the HTTP proxy. If you are using Windows or Kerberos authentication, set this property to a username in one of the following formats:

user@domain
domain\user

 

 

Pseudo Columns

Data Type

string

Default Value

""

Remarks

This setting is particularly helpful in Entity Framework, which does not allow you to set a value for a pseudo column unless it is a table column. The value of this connection setting is of the format "Table1=Column1, Table1=Column2, Table2=Column3". You can use the "*" character to include all tables and all columns; i.e., "*=*".

 

Readonly

Data Type

bool

Default Value

false

Remarks

If this property is set to true, the driver will allow only SELECT queries. INSERT, UPDATE, DELETE, and stored procedure queries will cause an error to be thrown.

 

RTK

Data Type

string

Default Value

""

Remarks

The RTK property may be used to license a build. Please see the included licensing file to see how to set this property. The runtime key is only available if you purchased an OEM license.

 

SSL Server Cert

Data Type

string

Default Value

""

Remarks

If using a TLS/SSL connection, this property can be used to specify the TLS/SSL certificate to be accepted from the server. Any other certificate that is not trusted by the machine will be rejected.

This property can take the forms:

 

   
Description Example
A full PEM Certificate (example shortened for brevity) -----BEGIN CERTIFICATE----- MIIChTCCAe4CAQAwDQYJKoZIhv......Qw== -----END CERTIFICATE-----
A path to a local file containing the certificate C:\cert.cer
The public key (example shortened for brevity) -----BEGIN RSA PUBLIC KEY----- MIGfMA0GCSq......AQAB -----END RSA PUBLIC KEY-----
The MD5 Thumbprint (hex values can also be either space or colon separated) ecadbdda5a1529c58a1e9e09828d70e4
The SHA1 Thumbprint (hex values can also be either space or colon separated) 34a929226ae0819f2ec14b4a3d904f801cbb150d

 

If not specified, any certificate trusted by the machine will be accepted. Use '*' to signify to accept all certificates (not recommended for security concerns).

 

Tables

Data Type

string

Default Value

""

Remarks

Listing the tables from some databases can be expensive. Providing a list of tables in the connection string improves the performance of the driver.

 

Timeout

Data Type

string

Default Value

"60"

Remarks

If the Timeout property is set to 0, operations do not time out: They run until they complete successfully or encounter an error condition.

If Timeout expires and the operation is not yet complete, the driver throws an exception.

 

Use Connection Pooling

Data Type

string

Default Value

"false"

Remarks

Enables connection pooling. The default is false. See Connection Pooling for information on using connection pools.

 

Verbosity

Data Type

string

Default Value

"1"

Remarks

The verbosity level determines the amount of detail that the driver reports to the Logfile. Verbosity levels from 1 to 5 are supported. These are described below:

 

   
1 Setting Verbosity to 1 will log the query, the number of rows returned by it, the start of execution and the time taken, and any errors.
2 Setting Verbosity to 2 will log everything included in Verbosity 1, cache queries, and HTTP headers.
3 Setting Verbosity to 3 will additionally log the body of the HTTP requests.
4 Setting Verbosity to 4 will additionally log transport-level communication with the data source. This includes SSL negotiation.
5 Setting Verbosity to 5 will additionally log communication with the data source and additional details that may be helpful in troubleshooting problems. This includes interface commands.

The Verbosity should not be set to greater than 1 for normal operation. Substantial amounts of data can be logged at higher verbosities, which can delay execution times.

 

Views

Data Type

string

Default Value

""

Remarks

Listing the Views from some databases can be expensive. Providing a list of Views in the connection string improves the performance of the driver.




 

Tables

  1. GroupItems
  2. Groups

GroupItems

Create, delete, and query Items that compose a Group.

 

Table-Specific Information

 

 

Select

 

When selecting GroupItems you must provide a GroupId.

SELECT * FROM GroupItems WHERE GroupId='239_65GrkKS6kRL'
Additionally, OnBehalfOfContentOwner can optionally be used in the WHERE clause.
Insert

 

GroupId and Resource_Id are required to insert an Item into a Group.

INSERT INTO GroupItems (GroupId, Resource_Id) VALUES ('fjgeeljgio54','dkhgjio5sfff')
Columns

 

 

 

   
Name Type ReadOnly Description
Id [KEY] String True

The Id that YouTube uses to uniquely identify the channel, video, playlist, or asset that is included in the group. Note that this Id refers specifically to the inclusion of that entity in a particular group and is different than the channel Id, video Id, playlist Id, or asset Id that uniquely identifies the entity itself.

Kind String False

Identifies the type of the group item. The value will be youtube#groupItem.

Etag String False

The Etag of this item.

GroupId String False

The Id that YouTube uses to uniquely identify the group that contains the item.

Resource_Kind String False

The type of the group item. The allowed values are youtube#channel, youtube#playlist, youtube#video, youtubePartner#asset.

Resource_Id String False

The channel, video, playlist, or asset Id that YouTube uses to uniquely identify the group item.

OnBehalfOfContentOwner String False

This parameter is intended exclusively for YouTube content partners that own and manage many different YouTube channels. The OnBehalfOfContentOwner parameter indicates that the authorization credentials in the request identify a YouTube user who is acting on behalf of the content owner specified in the parameter value.

 

 

 

Groups

Create, update, delete, and query YouTube Analytics Groups.

 

Table-Specific Information

 

A Group is a custom collection of up to 200 channels, videos, playlists, or assets. All of the Items in a Group must represent the same type of entity. For example, you cannot create a Group that contains 100 videos and 100 playlists. An Analytics Group can only contain entities that you have uploaded or claimed or that are linked to a channel that you administer. As a result, content owners can create groups of videos, playlists, channels, or assets. Channel owners can create groups of videos and playlists.

Select

 

The following columns can be used in the WHERE clause: OnBehalfOfContentOwner and Mine.

Insert

 

ContentDetails_ItemType is required to insert a Group.

INSERT INTO Groups (Snippet_Title, ContentDetails_ItemType) VALUES ('test2', 'youtube#channel')
Columns

 

 

 

   
Name Type ReadOnly Description
Id [KEY] String False

The Id that YouTube uses to uniquely identify the group.

Kind String False

Identifies the type of the YouTube Analytics entity. The value will be youtube#group.

Etag String False

The Etag of this resource.

Snippet_PublishedAt DateTime True

The date and time that the group was created.

Snippet_Title String False

The group name. The value must be a nonempty string.

ContentDetails_ItemCount String False

The number of items in the group.

ContentDetails_ItemType String False

The type of entities that the group contains. The allowed values are youtube#channel, youtube#playlist, youtube#video, youtubePartner#asset.

Mine String False

Set this to true to retrieve all groups owned by the authenticated user.

PageToken String False

The PageToken parameter identifies a specific page in the result set that should be returned.

OnBehalfOfContentOwner String False

This parameter is intended exclusively for YouTube content partners that own and manage many different YouTube channels. The OnBehalfOfContentOwner parameter indicates that the authorization credentials in the request identify a YouTube user who is acting on behalf of the content owner specified in the parameter value.

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String

Identifier for the next page of results. Do not set this value manually.

 

 




 

Views

  1. AdPerformanceReports
  2. Demographics
  3. Devices
  4. EngagementReports
  5. TimeBasedReports
  6. TopVideos
  7. TrafficSources

AdPerformanceReports

Query Ad Performance Reports. Ad Performance Reports provide impression-based metrics for ads that ran during video playbacks. These metrics account for each ad impression, and each video playback can yield multiple impressions.

 

Table Specific Information
Select

 

Get GrossRevenue for a video in a specific country grouped by ad type and day:

SELECT Country, AdType, Day, GrossRevenue, StartDate, EndDate FROM AdPerformanceReports WHERE video='vid123' and continent = '019'
Select Rules

 

 

Ad performance reports for content owners:

 

   
Dimensions Required adType
  Optional day
Metrics Use 1 or more grossRevenue,adImpressions,cpm
Filter Use exactly one video, group, or a supported combination of uploaderType and claimedStatus
  Use 0 or one country,continent,subContinent

 

Columns

 

 

 

   
Name Type Dimension DefaultMetric DefaultDimension Description
Video String True     The Id of a YouTube video.
Group String True     (filter only) The Id of a YouTube Analytics group.
Country String       The country associated with the metrics in the report row. The dimension value is a two-letter ISO-3166-1 country code, such as US, CN (China), or FR (France). The country code ZZ is used to report metrics for which YouTube could not identify the associated country.
Continent String       (filter only) A United Nations (U.N.) statistical region code. The allowed values are 002 Africa, 019 Americas (Northern America, Latin America, South America, and the Caribbean), 142 Asia, 150 Europe, 009 Oceania. This dimension can only be used to filter data.
SubContinent String       (filter only) A U.N. statistical region code that identifies a geographical subregion.
AdType String True     The AdType dimension is used in ad performance reports and aggregates the requested metrics based on the types of ads that ran during video playbacks: auctionDisplay, auctionInstream, auctionTrueviewInslate, auctionTrueviewInstream, auctionUnknown, reservedClickToPlay, reservedDisplay, reservedInstream, reservedInstreamSelect, reservedMasthead, reservedUnknown.
Day String True     When you use this dimension, data in the report is aggregated on a daily basis and each row contains data for one day.
ClaimedStatus String       (only used in content owner reports) This dimension lets you indicate that a result set should only contain metrics for claimed content. The allowed value is claimed.
UploaderType String       (only used in content owner reports) This dimension lets you indicate whether a result set should contain metrics for content uploaded by the specified content owner or content uploaded by third parties, such as user-uploaded videos. The allowed values are self and thirdParty.
GrossRevenue Double   False   The estimated gross revenue, in USD, from all Google-sold or DoubleClick-partner-sold advertising for the selected date range and region. Gross revenue is subject to month-end adjustment and does not include partner-served advertising. Gross revenue should not be confused with earnings, or net revenue, which factors in your share of ownership and revenue-sharing agreements.
Cpm Double   False   The estimated gross revenue per thousand ad impressions.
AdImpressions Double   False   The number of verified ad impressions served.
StartDate Datetime       Start date for fetching Analytics data.
EndDate Datetime       End date for fetching Analytics data.

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String Identifier for the next page of results. Do not set this value manually.
Segments String Segments the data returned for your request. Either a SegmentId or a custom segment.

 

 

 

Demographics

Query YouTubeAnalytics Demographics grouped by age groups and gender.

 

Table Specific Information
Select

 

 

Aggregate viewing statistics for videos based on viewers' age group and gender:

SELECT * FROM Demographics

 

Trim down Demographics for just one Video:

SELECT * FROM Demographics WHERE Video='kJ_JCdiWdWs'

 

Aggregate viewing statistics for playlists based on viewers' age group and gender:

SELECT * FROM Demographics WHERE IsCurated=true
Select Rules

 

You can use the following tables to build other queries to Top Videos.

Demographics for videos:

 

   
Dimensions Use 1 or more ageGroup,gender
  Use 0 or more liveOrOnDemand,subscribedStatus,youtubeProduct
Metrics Use 1 or more viewerPercentage
Filter Use 0 or one country,province,continent,subContinent
  Use 0 or one video,group
  Use 0 or more liveOrOnDemand,subscribedStatus,youtubeProduct

 

Demographics for playlists:

 

   
Dimensions Use 1 or more ageGroup,gender
  Use 0 or more subscribedStatus,youtubeProduct
Metrics Required viewerPercentage
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one video,group
  Use 0 or more subscribedStatus,youtubeProduct

 

Demographics for content owners:

 

   
Dimensions Use 1 or more ageGroup,gender
  Use 0 or more liveOrOnDemand,subscribedStatus,youtubeProduct
Metrics Use 1 or more viewerPercentage
Filter Use exactly one video,channel,group
  Use 0 or one country,province,continent,subContinent
  Use 0 or more liveOrOnDemand,subscribedStatus,youtubeProduct

 

Demographics for content owner playlists:

 

   
Dimensions Use 1 or more ageGroup,gender
  Use 0 or more subscribedStatus,youtubeProduct
Metrics Required viewerPercentage
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one playlist,channel,group
  Use 0 or more subscribedStatus,youtubeProduct

 

Columns

 

 

 

   
Name Type Dimension DefaultMetric DefaultDimension Description
Video String True   false The Id of a YouTube video.
Playlist String True     The Id of a YouTube playlist.
Group String True     (filter only) The Id of a YouTube Analytics group.
Country String True     The country associated with the metrics in the report row. The dimension value is a two-letter ISO-3166-1 country code, such as US, CN (China), or FR (France). The country code ZZ is used to report metrics for which YouTube could not identify the associated country.
Province String True     The U.S. state or territory associated with the metrics in the report row. The dimension value is an ISO 3166-2 code that identifies a U.S. state or the District of Columbia, such as US-MI (Michigan) or US-TX (Texas). The province code US-ZZ is used to report metrics for which YouTube could not identify the associated U.S. state. If the Province column is specified, Country must be set to US in the WHERE clause.
Continent String True     (filter only) A United Nations (U.N.) statistical region code. The API supports the following values: 002 Africa, 019 Americas (Northern America, Latin America, South America, and the Caribbean), 142 Asia, 150 Europe, 009 Oceania.
SubContinent String True     (filter only) A U.N. statistical region code that identifies a geographical subregion.
LiveOrOnDemand String True     This dimension indicates whether the user activity metrics in the data row are associated with views of a live broadcast. Data for this dimension is available for dates beginning April 1, 2014. The allowed values are LIVE, ON_DEMAND.
SubscribedStatus String True     This dimension indicates whether the user activity metrics in the data row are associated with viewers who were subscribed to the video or playlist channel. The allowed values are SUBSCRIBED and UNSUBSCRIBED. Note that the dimension value is accurate as of the time that the user activity occurs.
YoutubeProduct String True     This dimension identifies the YouTube service on which the user activity occurred. Data for this dimension is available as of July 18, 2015. The allowed values are CORE, GAMING, KIDS, UNKNOWN.
IsCurated Boolean True     This filter indicates that the request is retrieving data about video views that occurred in the context of a playlist. This filter is required for any playlist report and its value must be set to 1.
ClaimedStatus String True     (only used in content owner reports) This dimension lets you indicate that a result set will only contain metrics for claimed content. The allowed value is claimed.
UploaderType String True     (only used in content owner reports) This dimension lets you indicate whether a result set will contain metrics for content uploaded by the specified content owner or content uploaded by third parties, such as user-uploaded videos. The allowed values are self and thirdParty.
AgeGroup String True   True This dimension identifies the age group of the logged-in users associated with the report data. The allowed values are age13-17, age18-24, age25-34, age35-44, age45-54, age55-64, age65-
Gender String True   False This dimension identifies the gender of the logged-in users associated with the query. The allowed values are female and male.
ViewerPercentage Double False True   The percentage of viewers who were logged in when watching the video or playlist. The viewerPercentage values in this report are not normalized for different values or combinations of values for playback detail dimensions (subscribedStatus and youtubeProduct). For example, a report that uses the subscribedStatus dimension returns viewerPercentage data adding up to 100 percent for subscribed views and viewerPercentage data adding up to 100 percent for unsubscribed views. (The total value of all viewerPercentage fields in the report is 200 percent.) You can use filters to ensure that the report only contains viewerPercentage data for one value (or combination of values) for playback detail dimensions.
StartDate Datetime       Start date for fetching Analytics data.
EndDate Datetime       End date for fetching Analytics data.

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String Identifier for the next page of results. Do not set this value manually.
Segments String Segments the data returned for your request. Either a SegmentId or a custom segment.

 

 

 

Devices

Query YouTubeAnalytics Devices or Operating System statistics. This table allows you to aggregate viewing statistics based on the manner in which viewers reached your video content. For example, you can identify the number of views that occurred on mobile devices or game consoles.

 

Table Specific Information
Select

 

 

By default, grouping is done by Device Type:

SELECT * FROM Devices

 

However, you can group views by other dimensions such as Operating System:

SELECT OperatingSystem, Views, EstimatedMinutesWatched FROM Devices
Notice that you cannot mix both Device Type and Operating System in the same query due to limitations in the YouTube Analytics API.
Select Rules

 

You can use the following tables to build other queries to Devices:

Devices for videos:

 

   
Dimensions Use exactly one deviceType,operatingSystem
  Use 0 or more day,liveOrOnDemand,subscribedStatus,youtubeProduct
Metrics Use 1 or more views,estimatedMinutesWatched
Filter Use 0 or one country,province,continent,subContinent
  Use 0 or one video,group
  Use 0 or more operatingSystem,liveOrOnDemand,subscribedStatus,youtubeProduct

 

Device data for playlists:

 

   
Dimensions Use exactly one deviceType,operatingSystem
  Use 0 or more day,subscribedStatus,youtubeProduct
Metrics Use 1 or more views,estimatedMinutesWatched,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one playlist,channel,group
  Use 0 or more operatingSystem,subscribedStatus,youtubeProduct

 

Device data for content owners:

 

   
Dimensions Required deviceType
  Use 0 or more day,liveOrOnDemand,subscribedStatus,youtubeProduct
Metrics Use 1 or more views,estimatedMinutesWatched
Filter Use exactly one video,channel,group
  Use 0 or one country,province,continent,subContinent
  Use 0 or more operatingSystem,liveOrOnDemand,subscribedStatus,youtubeProduct

 

Device data for content owner playlists:

 

   
Dimensions Required deviceType
  Use 0 or more day,subscribedStatus,youtubeProduct
Metrics Use 1 or more views,estimatedMinutesWatched,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist
Filters Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one playlist,channel,group
  Use 0 or more operatingSystem,subscribedStatus,youtubeProduct

 

 

Columns

 

 

 

   
Name Type Dimension DefaultMetric DefaultDimension Description
Video String True     The Id of a YouTube video.
Group String True     (filter only) The Id of a YouTube Analytics group.
Channel String True     (only used in content owner reports) The Id for a YouTube channel. The channel dimension is frequently used in content owner reports because those reports typically aggregate data for multiple channels.
Playlist String True     The Id of a YouTube playlist.
Country String True     The country associated with the metrics in the report row. The dimension value is a two-letter ISO-3166-1 country code, such as US, CN (China), or FR (France). The country code ZZ is used to report metrics for which YouTube could not identify the associated country.
Province String True     The U.S. state or territory associated with the metrics in the report row. The dimension value is an ISO 3166-2 code that identifies a U.S. state or the District of Columbia, such as US-MI (Michigan) or US-TX (Texas). The province code US-ZZ is used to report metrics for which YouTube could not identify the associated U.S. state. If the Province column is specified, Country must be set to US in the WHERE clause.
Continent String True     (filter only) A United Nations (U.N.) statistical region code: 002 Africa, 019 Americas (Northern America, Latin America, South America, and the Caribbean), 142 Asia, 150 Europe, 009 Oceania. This dimension can only be used to filter data.
SubContinent String True     (filter only) A U.N. statistical region code that identifies a geographical subregion.
Day String True     When you use this dimension, data in the report is aggregated on a daily basis and each row contains data for one day.
LiveOrOnDemand String True     This dimension indicates whether the user activity metrics in the data row are associated with views of a live broadcast. Data for this dimension is available for dates beginning April 1, 2014. The allowed values are LIVE, ON_DEMAND.
SubscribedStatus String True     This dimension indicates whether the user activity metrics in the data row are associated with viewers who were subscribed to the video or playlist channel. The allowed values are SUBSCRIBED, UNSUBSCRIBED. Note that the dimension value is accurate as of the time that the user activity occurs.
YoutubeProduct String True     This dimension identifies the YouTube service on which the user activity occurred. Data for this dimension is available as of July 18, 2015. The allowed values are CORE, GAMING, KIDS, UNKNOWN.
DeviceType String True   True This dimension identifies the physical form factor of the device on which the view occurred. The allowed values are DESKTOP, GAME_CONSOLE, MOBILE, TABLET, TV, UNKNOWN_PLATFORM.
OperatingSystem String True   False This dimension identifies the software system of the device on which the view occurred. The allowed values are ANDROID, BADA, BLACKBERRY, DOCOMO, HIPTOP, IOS, LINUX, MACINTOSH, MEEGO, NINTENDO_3DS, OTHER, PLAYSTATION, PLAYSTATION_VITA, SMART_TV, SYMBIAN, WEBOS.
IsCurated Boolean True     This filter indicates that the request is retrieving data about video views that occurred in the context of a playlist. This filter is required for any playlist report and its value must be set to 1.
ClaimedStatus String True     (only used in content owner reports) This dimension lets you indicate that the result set will only contain metrics for claimed content. The allowed value is claimed.
UploaderType String True     (only used in content owner reports) This dimension lets you indicate whether the result set will contain metrics for content uploaded by the specified content owner or content uploaded by third parties, such as user-uploaded videos. The allowed values are self and thirdParty.
Views Double False True   The number of times that a video was viewed.
EstimatedMinutesWatched Double False True   The number of minutes that users watched videos for the specified channel, content owner, video, or playlist.
PlaylistStarts Double False False   The number of times that viewers initiated playback of a playlist.
ViewsPerPlaylistStart Double False False   The average number of video views that occurred each time a playlist was initiated.
AverageTimeInPlaylist Double False False   The estimated average amount of time, in minutes, that a viewer viewed videos in a playlist after the playlist was initiated.
StartDate Datetime       Start date for fetching Analytics data.
EndDate Datetime       End date for fetching Analytics data.

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String Identifier for the next page of results. Do not set this value manually.
Segments String Segments the data returned for your request. Either a SegmentId or a custom segment.

 

 

 

EngagementReports

Query Engagement Reports info. For example, how many times a user shared a video.

 

Table Specific Information
Select

 

By default, results are grouped by Day. The following query returns Comments, Likes, Dislikes, etc., grouped by Day:

SELECT * FROM EngagementReports
Select Rules

 

The following query returns how frequently the channel's videos were shared on different social platforms:

SELECT SharingService, Shares FROM EngagementReports
You can use the following tables to build other queries to Engagement Reports:

 

Engagement Reports for videos:

 

   
Dimensions Required sharingService
  Optional subscribedStatus
Metrics Use 1 or more shares
Filter Use 0 or one country,continent,subContinent
  Use 0 or one video,group
  Optional subscribedStatus

 

Engagement Reports for content owners:

 

   
Dimensions Required sharingService
  Optional subscribedStatus
Metrics Use 1 or more shares
Filter Use exactly one video,channel,group
  Use 0 or one country,continent,subContinent
  Optional subscribedStatus

 

Columns

 

 

 

   
Name Type Dimension DefaultMetric DefaultDimension Description
SharingService String True     This dimension identifies the service that was used to share videos. Videos can be shared on YouTube (or via the YouTube player) using the Share button.
Channel String True     (only used in content owner reports) The Id for a YouTube channel. The channel dimension is frequently used in content owner reports because those reports typically aggregate data for multiple channels.
Video String True     The Id of a YouTube video.
Group String True     (filter only) The Id of a YouTube Analytics group.
Country String True     The country associated with the metrics in the report row. The dimension value is a two-letter ISO-3166-1 country code, such as US, CN (China), or FR (France). The country code ZZ is used to report metrics for which YouTube could not identify the associated country.
Continent String True     (filter only) A United Nations (U.N.) statistical region code: 002 Africa, 019 Americas (Northern America, Latin America, South America, and the Caribbean), 142 Asia, 150 Europe, 009 Oceania. This dimension can only be used to filter data.
SubContinent String True     (filter only) A U.N. statistical region code that identifies a geographical subregion.
SubscribedStatus String True     This dimension indicates whether the user activity metrics in the data row are associated with viewers who were subscribed to the video or playlist channel. Possible values are SUBSCRIBED and UNSUBSCRIBED. Note that the dimension value is accurate as of the time that the user activity occurs.
ClaimedStatus String True     (only used in content owner reports) This dimension lets you indicate that a result set will only contain metrics for claimed content. The allowed value is claimed.
UploaderType String True     (only used in content owner reports) This dimension lets you indicate whether a result set will contain metrics for content uploaded by the specified content owner or content uploaded by third parties, such as user-uploaded videos. The allowed values are self and thirdParty.
Shares Double False True   The number of times that users shared a video through the Share button.
StartDate Datetime       Start date for fetching Analytics data.
EndDate Datetime       End date for fetching Analytics data.

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String Identifier for the next page of results. Do not set this value manually.
Segments String Segments the data returned for your request. Either a SegmentId or a custom segment.

 

 

 

TimeBasedReports

Query time-based info on views, subscribers, etc. For example, how many new subscribers were gained at a specific time.

 

Table-Specific Information
Select Rules
You can use the following tables to build queries to TimeBased Reports: TimeBased Reports for videos:

 

   
Dimensions Use exactly one day,7DayTotals,30DayTotals,month
Metrics Use 1 or more views,comments,likes,dislikes,videosAddedToPlaylists,videosRemovedFromPlaylists,shares,estimatedMinutesWatched,averageViewDuration,averageViewPercentage,annotationClickThroughRate,annotationCloseRate,annotationImpressions,annotationClickableImpressions,annotationClosableImpressions,annotationClicks,annotationCloses,subscribersGained,subscribersLost,uniques,earnings,adEarnings,grossRevenue,redPartnerRevenue,monetizedPlaybacks,playbackBasedCpm,impressions,impressionBasedCpm
Filter Use 0 or one country,continent,subContinent
  Use 0 or one video,group

 

Timebased Reports for playlist rules:

 

   
Dimensions Use exactly one day,7DayTotals,30DayTotals,month
  Use 0 or more subscribedStatus,youtubeProduct
Metrics Use 1 or more views,estimatedMinutesWatched,averageViewDuration,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one playlist,channel,group
  Use 0 or more subscribedStatus,youtubeProduct

 

Timebased Reports for content owner rules:

 

   
Dimensions Use exactly one day,7DayTotals,30DayTotals,month
Metrics Use 1 or more views,comments,likes,dislikes,videosAddedToPlaylists,videosRemovedFromPlaylists,shares,estimatedMinutesWatched,averageViewDuration,averageViewPercentage,annotationClickThroughRate,annotationCloseRate,annotationImpressions,annotationClickableImpressions,annotationClosableImpressions,annotationClicks,annotationCloses,subscribersGained,subscribersLost,uniques,earnings,adEarnings,grossRevenue,redPartnerRevenue,monetizedPlaybacks,playbackBasedCpm,impressions,impressionBasedCpm
Filter Use exactly one video,channel,group
  Use 0 or one country,continent,subContinent

 

Timebased Reports for content owner playlist rules:

 

   
Dimensions Use exactly one day,7DayTotals,30DayTotals,month
  Use 0 or more subscribedStatus,youtubeProduct
Metrics Use 1 or more views,estimatedMinutesWatched,averageViewDuration,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylis
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one playlist,channel,group
  Use 0 or more subscribedStatus,youtubeProduct

 

Columns

 

 

 

   
Name Type Dimension DefaultMetric DefaultDimension Description
Channel String True     (only used in content owner reports) The Id for a YouTube channel. The channel dimension is frequently used in content owner reports because those reports typically aggregate data for multiple channels.
Video String True     The Id of a YouTube video.
Group String True     (filter only) The Id of a YouTube Analytics group.
Playlist String True     The Id of a YouTube playlist.
Country String True     The country associated with the metrics in the report row. The dimension value is a two-letter ISO-3166-1 country code, such as US, CN (China), or FR (France). The country code ZZ is used to report metrics for which YouTube could not identify the associated country.
Province String True     The U.S. state or territory associated with the metrics in the report row. The dimension value is an ISO 3166-2 code that identifies a U.S. state or the District of Columbia, such as US-MI (Michigan) or US-TX (Texas). The province code US-ZZ is used to report metrics for which YouTube could not identify the associated U.S. state. If the Province column is specified, Country must be set to US in the WHERE clause.
Continent String True     (filter only) A United Nations (U.N.) statistical region code. The API supports the following values: 002 Africa, 019 Americas (Northern America, Latin America, South America, and the Caribbean), 142 Asia, 150 Europe, 009 Oceania. This dimension can only be used to filter data.
SubContinent String True     (filter only) A U.N. statistical region code that identifies a geographical subregion.
Day String True   True When you use this dimension, data in the report is aggregated on a daily basis and each row contains data for one day.
SevenDayTotals String True     Data in the report is aggregated so that each row contains data for a seven-day period. In the report, the SevenDayTotals column specifies the end date of a seven-day period.
ThirtyDayTotals String True     Data in the report is aggregated so that each row contains data for a 30-day period. In the report, the ThirtyDayTotals column or property specifies the end date of a 30-day period. Note: The Uniques metric specifies the number of unique cookies associated with views in the 30-day period. (This number overcounts users who are using multiple devices or browsers.)
Month String True     Data in the report is aggregated by calendar month. In the report, dates are listed in YYYY-MM format. Note: If your SQL query uses the Month dimension, then the StartDate and EndDate parameters must both be set to the first day of the month.
IsCurated Boolean True     This filter indicates that the request is retrieving data about video views that occurred in the context of a playlist. This filter is required for any playlist report and its value must be set to 1.
ClaimedStatus String True     (only used in content owner reports) This dimension lets you indicate that a result set will only contain metrics for claimed content. The allowed value is claimed.
UploaderType String True     (only used in content owner reports) This dimension lets you indicate whether a result set will contain metrics for content uploaded by the specified content owner or content uploaded by third parties, such as user-uploaded videos. The allowed values are self and thirdParty.
SubscribedStatus String True     This dimension indicates whether the user activity metrics in the data row are associated with viewers who were subscribed to the video or playlist channel. Possible values are SUBSCRIBED and UNSUBSCRIBED. Note that the dimension value is accurate as of the time that the user activity occurs.
YoutubeProduct String True     This dimension identifies the YouTube service on which the user activity occurred. Data for this dimension is available as of July 18, 2015. The allowed values are CORE, GAMING, KIDS, UNKNOWN.
Views Double False False   The number of times that a video was viewed. In a playlist report, the metric indicates the number of times that a video was viewed in the context of a playlist.
ViewerPercentage Double False False   The percentage of viewers who were logged in when watching the video or playlist.
EstimatedMinutesWatched Double False False   The number of minutes that users watched videos for the specified channel, content owner, video, or playlist.
AverageViewDuration Double False False   The average length, in seconds, of video playbacks. In a playlist report, the metric indicates the average length, in seconds, of video playbacks that occurred in the context of a playlist.
AverageViewPercentage Double False True   The average percentage of a video watched during a video playback.
Comments Double False True   The number of times that users commented on a video.
Likes Double False False   The number of times that users indicated that they liked a video by giving it a positive rating.
Dislikes Double False True   The number of times that users indicated that they disliked a video by giving it a negative rating. This is a core metric and is subject to the Deprecation Policy.
Shares Double False True   The number of times that users shared a video through the Share button.
SubscribersGained Double False True   The number of times that users subscribed to a channel or video.
SubscribersLost Double False True   The number of times that users unsubscribed from a channel or video.
VideosAddedToPlaylists Double False True   The number of times that videos were added to the video owner playlist or other channel playlists like the Watch Later playlist. Channel uploads playlists and user watch history are not reported. This metric returns an absolute number, meaning that if a user adds a video to a playlist, removes it, and then adds it again, the metric value reflects the video being added to a playlist twice. Data for this metric is not available for dates before October 1, 2014.
VideosRemovedFromPlaylists Double False True   The number of times that videos were removed from the video owner playlist and other YouTube playlists like the Watch Later playlist. This metric returns an absolute number, meaning that if a user adds a video to a playlist, removes it, adds it again, and then removes it again, the metric value reflects the video being removed from a playlist twice. Data for this metric is not available for dates before October 1, 2014.
PlaylistStarts Double False False   The number of times that viewers initiated playback of a playlist.
ViewsPerPlaylistStart Double False False   The average number of video views that occurred each time a playlist was initiated.
AverageTimeInPlaylist Double False False   The estimated average amount of time, in minutes, that a viewer viewed videos in a playlist after the playlist was initiated.
AnnotationImpressions Double False True   The total number of annotation impressions.
AnnotationClickableImpressions Double False True   The number of annotations that appeared and could be clicked.
AnnotationClicks Double False True   The number of clicked annotations.
AnnotationClickThroughRate Double False True   The ratio of annotations that viewers clicked to the total number of clickable annotation impressions.
AnnotationClosableImpressions Double False True   The number of annotations that appeared and could be closed.
AnnotationCloses Double False True   The number of closed annotations.
AnnotationCloseRate Double False True   The ratio of annotations that viewers closed to the total number of annotation impressions.
EstimatedRevenue Double False False   The total estimated earnings (net revenue) from all Google-sold advertising sources as well as from nonadvertising sources for the selected date range and region. Estimated earnings are subject to month-end adjustment and do not include partner-sold and partner-served advertising.
EstimatedAdRevenue Double False False   The total estimated earnings (net revenue) from all Google-sold advertising sources for the selected date range and region. Estimated earnings are subject to month-end adjustment and do not include partner-sold and partner-served advertising.
EstimatedRedPartnerRevenue Double False False   The total estimated revenue earned from YouTube Red subscriptions for the selected report dimensions. The value of the metric reflects earnings from both music and nonmusic content and is subject to month-end adjustment.
GrossRevenue Double False False   The estimated gross revenue, in USD, from all Google-sold or DoubleClick-partner-sold advertising for the selected date range and region. Gross revenue is subject to month-end adjustment and does not include partner-served advertising. Gross revenue should not be confused with earnings, or net revenue, which factors in your share of ownership and revenue-sharing agreements.
Cpm Double False False   The estimated gross revenue per thousand ad impressions.
AdImpressions Double False False   The number of verified ad impressions served.
MonetizedPlaybacks Double False False   The number of instances when a viewer played your video and was shown at least one ad impression. A monetized playback is counted if a viewer is shown a preroll ad but quits watching the ad before your video ever starts. The expected estimated error for this figure is Ѳ.0%.
PlaybackBasedCpm Double False False   The estimated gross revenue per thousand playbacks.
StartDate Datetime       Start date for fetching Analytics data.
EndDate Datetime       End date for fetching Analytics data.

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String Identifier for the next page of results. Do not set this value manually.
Segments String Segments the data returned for your request. Either a SegmentId or a custom segment.

 

 

 

TopVideos

Query the TopVideos for a channel or the TopPlaylists if you are a content owner. You can also use this view to query playback detail and geographic filters.

 

Table Specific Information
Select

 

The following query returns a channel's top videos by most minutes watched:

SELECT * FROM TopVideos

 

The following query returns a channel's top videos by most minutes watched in a specific country:

SELECT Video, Views, EstimatedMinutesWatched, AverageViewDuration, AverageViewPercentage FROM TopVideos WHERE Country='AL'

 

The following query returns a channel's top playlists by most minutes watched:

SELECT Playlist, Views, EstimatedMinutesWatched, PlaylistStarts, AverageViewDuration FROM TopVideos WHERE IsCurated=true
Select Rules

 

You can use the following tables to build other queries to Top Videos:

Top Videos for videos:

 

   
Dimensions Required video
Metrics Use 1 or more views,comments,likes,dislikes,videosAddedToPlaylists,videosRemovedFromPlaylists,shares,estimatedMinutesWatched,averageViewDuration,averageViewPercentage,annotationClickThroughRate,annotationCloseRate,annotationImpressions,annotationClickableImpressions,annotationClosableImpressions,annotationClicks,annotationCloses,subscribersGained,subscribersLost
Filter Use 0 or one country,continent,subContinent
Sort Use 0 or more (only descending order) views,estimatedMinutesWatched,subscribersGained,subscribersLost

 

Top Videos for playlists:

 

   
Dimensions Required playlist
Metrics Use 1 or more views,estimatedMinutesWatched,averageViewDuration,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or more playlist,subscribedStatus,youtubeProduct
Sort Use 0 or more (only descending order) views,estimatedMinutesWatched,playlistStarts

 

Top Videos for content owners:

 

   
Dimensions Required video
Metrics Use 1 or more views,comments,likes,dislikes,videosAddedToPlaylists,videosRemovedFromPlaylists,shares,estimatedMinutesWatched,averageViewDuration,averageViewPercentage,annotationClickThroughRate,annotationCloseRate,annotationImpressions,annotationClickableImpressions,annotationClosableImpressions,annotationClicks,annotationCloses,subscribersGained,subscribersLost,earnings,adEarnings,grossRevenue,redPartnerRevenue,monetizedPlaybacks,playbackBasedCpm,impressions,impressionBasedCpm
Filter Use exactly one channel
  Use 0 or one country,continent,subContinent
Sort Use 0 or more (only descending order) views,earnings,redPartnerRevenue,estimatedMinutesWatched,subscribersGained,subscribersLost

 

Top Videos for content owner playlists:

 

   
Dimensions Required playlist
Metrics Use 1 or more views,estimatedMinutesWatched,averageViewDuration,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist
Filter Required isCurated=true
  Use 0 or one playlist,channel
  Use 0 or one country,province,continent,subContinent
  Use 0 or more subscribedStatus,youtubeProduct
Sort Use 0 or more (only descending order) views,estimatedMinutesWatched,playlistStarts

 

Columns

 

 

 

   
Name Type Dimension DefaultMetric DefaultDimension Description
Channel String True     (only used in content owner reports) The Id for a YouTube channel. The channel dimension is frequently used in content owner reports because those reports typically aggregate data for multiple channels.
Video String True   true The Id of a YouTube video.
Playlist String True     The Id of a YouTube playlist.
Group String True     (filter only) The Id of a YouTube Analytics group.
Country String True     The country associated with the metrics in the report row. The dimension value is a two-letter ISO-3166-1 country code, such as US, CN (China), or FR (France). The country code ZZ is used to report metrics for which YouTube could not identify the associated country.
Province String True     The U.S. state or territory associated with the metrics in the report row. The dimension value is an ISO 3166-2 code that identifies a U.S. state or the District of Columbia, such as US-MI (Michigan) or US-TX (Texas). The province code US-ZZ is used to report metrics for which YouTube could not identify the associated U.S. state. If the Province column is specified, Country must be set to US in the WHERE clause.
Continent String True     (filter only) A United Nations (U.N.) statistical region code. The API supports the following values: 002 Africa, 019 Americas (Northern America, Latin America, South America, and the Caribbean), 142 Asia, 150 Europe, 009 Oceania. This dimension can only be used to filter data.
SubContinent String True     (filter only) A U.N. statistical region code that identifies a geographical subregion.
IsCurated Boolean True     This filter indicates that the request is retrieving data about video views that occurred in the context of a playlist. This filter is required for any playlist report and its value must be set to 1.
ClaimedStatus String True     (only used in content owner reports) This dimension lets you indicate that a result set will only contain metrics for claimed content. The allowed value is claimed.
UploaderType String True     (only used in content owner reports) This dimension lets you indicate whether a result set will contain metrics for content uploaded by the specified content owner or content uploaded by third parties, such as user-uploaded videos. The allowed values are self and thirdParty.
SubscribedStatus String True     This dimension indicates whether the user activity metrics in the data row are associated with viewers who were subscribed to the video or playlist channel. Possible values are SUBSCRIBED and UNSUBSCRIBED. Note that the dimension value is accurate as of the time that the user activity occurs.
YoutubeProduct String True     This dimension identifies the YouTube service on which the user activity occurred. Data for this dimension is available as of July 18, 2015. The allowed values are CORE, GAMING, KIDS, UNKNOWN.
Views Double False True   The number of times that a video was viewed. In a playlist report, the metric indicates the number of times that a video was viewed in the context of a playlist.
EstimatedMinutesWatched Double False True   The number of minutes that users watched videos for the specified channel, content owner, video, or playlist.
AverageViewDuration Double False True   The average length, in seconds, of video playbacks. In a playlist report, the metric indicates the average length, in seconds, of video playbacks that occurred in the context of a playlist.
AverageViewPercentage Double False False   The average percentage of a video watched during a video playback.
PlaylistStarts Double False False   The number of times that viewers initiated playback of a playlist.
Likes Double False False   The number of times that users indicated that they liked a video by giving it a positive rating.
ViewerPercentage Double False False   The percentage of viewers who were logged in when watching the video or playlist.
Comments Double False True   The number of times that users commented on a video.
Dislikes Double False True   The number of times that users indicated that they disliked a video by giving it a negative rating. This is a core metric and is subject to the Deprecation Policy.
Shares Double False True   The number of times that users shared a video through the Share button.
SubscribersGained Double False True   The number of times that users subscribed to a channel or video.
SubscribersLost Double False True   The number of times that users unsubscribed from a channel or video.
VideosAddedToPlaylists Double False True   The number of times that videos were added to the video owner playlist or other channel playlists like the Watch Later playlist. Channel uploads playlists and user watch history are not reported. This metric returns an absolute number, meaning that if a user adds a video to a playlist, removes it, and then adds it again, the metric value reflects the video being added to a playlist twice. Data for this metric is not available for dates before October 1, 2014.
VideosRemovedFromPlaylists Double False True   The number of times that videos were removed from the video owner playlist and other YouTube playlists like the Watch Later playlist. This metric returns an absolute number, meaning that if a user adds a video to a playlist, removes it, adds it again, and then removes it again, the metric value reflects the video being removed from a playlist twice. Data for this metric is not available for dates before October 1, 2014.
ViewsPerPlaylistStart Double False False   The average number of video views that occurred each time a playlist was initiated.
AverageTimeInPlaylist Double False False   The estimated average amount of time, in minutes, that a viewer viewed videos in a playlist after the playlist was initiated.
AnnotationImpressions Double False True   The total number of annotation impressions.
AnnotationClickableImpressions Double False True   The number of annotations that appeared and could be clicked.
AnnotationClicks Double False True   The number of clicked annotations.
AnnotationClickThroughRate Double False True   The ratio of annotations that viewers clicked to the total number of clickable annotation impressions.
AnnotationClosableImpressions Double False True   The number of annotations that appeared and could be closed.
AnnotationCloses Double False True   The number of closed annotations.
AnnotationCloseRate Double False True   The ratio of annotations that viewers closed to the total number of annotation impressions.
EstimatedRevenue Double False False   The total estimated earnings (net revenue) from all Google-sold advertising sources as well as from nonadvertising sources for the selected date range and region. Estimated earnings are subject to month-end adjustment and do not include partner-sold and partner-served advertising.
EstimatedAdRevenue Double False False   The total estimated earnings (net revenue) from all Google-sold advertising sources for the selected date range and region. Estimated earnings are subject to month-end adjustment and do not include partner-sold and partner-served advertising.
EstimatedRedPartnerRevenue Double False False   The total estimated revenue earned from YouTube Red subscriptions for the selected report dimensions. The value of the metric reflects earnings from both music and nonmusic content and is subject to month-end adjustment.
GrossRevenue Double False False   The estimated gross revenue, in USD, from all Google-sold or DoubleClick-partner-sold advertising for the selected date range and region. Gross revenue is subject to month-end adjustment and does not include partner-served advertising. Gross revenue should not be confused with earnings, or net revenue, which factors in your share of ownership and revenue-sharing agreements.
Cpm Double False False   The estimated gross revenue per thousand ad impressions.
AdImpressions Double False False   The number of verified ad impressions served.
MonetizedPlaybacks Double False False   The number of instances when a viewer played your video and was shown at least one ad impression. A monetized playback is counted if a viewer is shown a preroll ad but quits watching the ad before your video ever starts. The expected estimated error for this figure is Ѳ.0%.
PlaybackBasedCpm Double False False   The estimated gross revenue per thousand playbacks.
StartDate Datetime       Start date for fetching Analytics data. Either a date string or a relative date (e.g., today, yesterday, or #daysAgo).
EndDate Datetime       End date for fetching Analytics data. Either a date string or a relative date (e.g., today, yesterday, or #daysAgo).

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String Identifier for the next page of results. Do not set this value manually.
Segments String Segments the data returned for your request. Either a SegmentId or a custom segment.

 

 

 

TrafficSources

Query TrafficSources. Statistics are based on the manner in which viewers reached your video and playlist content.

 

Table Specific Information
Select

 

 

The following query aggregates viewing statistics based on the manner in which viewers reached your video content; for example, to identify the number of views that stemmed from a Google search or from a link to a related video.

SELECT * FROM TrafficSources

 

The following query displays the Views and EstimatedMinutesWatched metrics grouped by the Day and InsightTrafficSourceType dimensions:

SELECT Day, InsightTrafficSourceType, Views, EstimatedMinutesWatched FROM TrafficSources

 

The following query filters the statistics to be compiled for a specific Video and Country:

SELECT Day, InsightTrafficSourceType, Views, EstimatedMinutesWatched FROM TrafficSources WHERE Video='NsFGazHDggQ' AND Country='AL'

 

The following query aggregates viewing statistics based on the manner in which viewers reached your playlist content; for example, to identify the number of views that stemmed from a Google search.

SELECT InsightTrafficSourceType, Views, EstimatedMinutesWatched, PlaylistStarts, ViewsPerPlaylistStart, AverageTimeInPlaylist FROM TrafficSources WHERE IsCurated=true

 

The following query returns search terms that generated the most views from YouTube search results for videos located in playlists. Notice that ordering and limiting are required for such a query due to restrictions in the YouTube Analytics API.

SELECT InsightTrafficSourceDetail, Views, EstimatedMinutesWatched, PlaylistStarts, ViewsPerPlaylistStart, AverageTimeInPlaylist FROM TrafficSources WHERE IsCurated=true AND InsightTrafficSourceType='YT_SEARCH' ORDER BY Views DESC LIMIT 25
Select Rules

 

You can use the following tables to build other queries to Traffic Sources:

Traffic Sources for videos:

 

   
Dimensions Use exactly one insightTrafficSourceType,insightTrafficSourceDetail
  Use 0 or more day,liveOrOnDemand,subscribedStatus
Metrics Use 1 or more views,estimatedMinutesWatched
Filter Use 0 or one country,province,continent,subContinent
  Use 0 or one video,group
  Use 0 or more liveOrOnDemand,subscribedStatus
Sort Use 0 or more(only descending order) views,estimatedMinutesWatched

 

Traffic Sources for playlists:

 

   
Dimensions Use exactly one insightTrafficSourceType,insightTrafficSourceDetail
  Use 0 or more day,subscribedStatus
Metrics Use 1 or more views,estimatedMinutesWatched,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one playlist,channel,group
  Optional subscribedStatus
Sort Use 0 or more(only descending order) views,estimatedMinutesWatched,playlistStarts

 

Traffic Sources for content owners:

 

   
Dimensions Required insightTrafficSourceType
  Use 0 or more day,liveOrOnDemand,subscribedStatus
Metrics Use 1 or more views,estimatedMinutesWatched
Filter Use exactly one video,channel,group
  Use 0 or one country,province,continent,subContinent
  Use 0 or more liveOrOnDemand,subscribedStatus

 

Traffic Sources for content owner playlists:

 

   
Dimensions Required insightTrafficSourceType
  Use 0 or more day,subscribedStatus
Metrics Use 1 or more views,estimatedMinutesWatched,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist
Filter Required isCurated=true
  Use 0 or one country,province,continent,subContinent
  Use 0 or one playlist,channel,group
  Optional subscribedStatus

 

Columns

 

 

 

   
Name Type Dimension DefaultMetric DefaultDimension Description
Channel String True     (only used in content owner reports) The Id for a YouTube channel. The channel dimension is frequently used in content owner reports because those reports typically aggregate data for multiple channels.
Video String True     The Id of a YouTube video.
Playlist String True     The Id of a YouTube playlist.
Group String True     (filter only) The Id of a YouTube Analytics group.
Country String True     The country associated with the metrics in the report row. The dimension value is a two-letter ISO-3166-1 country code, such as US, CN (China), or FR (France). The country code ZZ is used to report metrics for which YouTube could not identify the associated country.
Province String True     The U.S. state or territory associated with the metrics in the report row. The dimension value is an ISO 3166-2 code that identifies a U.S. state or the District of Columbia, such as US-MI (Michigan) or US-TX (Texas). The province code US-ZZ is used to report metrics for which YouTube could not identify the associated U.S. state. If the Province column is specified, Country must be set to US in the WHERE clause.
Continent String True     (filter only) A United Nations (U.N.) statistical region code. The allowed values are 002 Africa, 019 Americas (Northern America, Latin America, South America, and the Caribbean), 142 Asia, 150 Europe, 009 Oceania. This dimension can only be used to filter data.
SubContinent String True     (filter only) A U.N. statistical region code that identifies a geographical subregion.
Day String True     When you use this dimension, data in the report is aggregated on a daily basis and each row contains data for one day.
LiveOrOnDemand String True     This dimension indicates whether the user activity metrics in the data row are associated with views of a live broadcast. Data for this dimension is available for dates beginning April 1, 2014. The allowed values are LIVE, ONDEMAND.
SubscribedStatus String True     This dimension indicates whether the user activity metrics in the data row are associated with viewers who were subscribed to the video or playlist channel. The allowed values are SUBSCRIBED, UNSUBSCRIBED. Note that the dimension value is accurate as of the time that the user activity occurs.
InsightTrafficSourceType String True   True Data in the report is aggregated based on the referrer type, which describes the manner in which users reached the video. The allowed values are ADVERTISING, ANNOTATION, EXT_URL, NO_LINK_EMBEDDED, NO_LINK_OTHER, NOTIFICATION, PLAYLIST, PROMOTED, RELATED_VIDEO, SUBSCRIBER, YT_CHANNEL, YT_OTHER_PAGE, YT_SEARCH.
InsightTrafficSourceDetail String True     Details about the InsightTrafficSourceType.
IsCurated Boolean True     This filter indicates that the request is retrieving data about video views that occurred in the context of a playlist. This filter is required for any playlist report and its value must be set to 1.
ClaimedStatus String True     (only used in content owner reports) This dimension lets you indicate that a result set will only contain metrics for claimed content. The allowed value is claimed.
UploaderType String True     (only used in content owner reports) This dimension lets you indicate whether a result set will contain metrics for content uploaded by the specified content owner or content uploaded by third parties, such as user-uploaded videos. The allowed values are self and thirdParty.
Views Double False True   The number of times that a video was viewed. In a playlist report, the metric indicates the number of times that a video was viewed in the context of a playlist.
EstimatedMinutesWatched Double False True   The number of minutes that users watched videos for the specified channel, content owner, video, or playlist.
PlaylistStarts Double False False   The number of times that viewers initiated playback of a playlist.
ViewsPerPlaylistStart Double False False   The average number of video views that occurred each time a playlist was initiated.
AverageTimeInPlaylist Double False False   The estimated average amount of time, in minutes, that a viewer viewed videos in a playlist after the playlist was initiated.
StartDate Datetime       Start date for fetching Analytics data.
EndDate Datetime       End date for fetching Analytics data.

 

Pseudo-Columns

 

 

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

 

 

   
Name Type Description
Rows@Next String Identifier for the next page of results. Do not set this value manually.
Segments String Segments the data returned for your request. Either a SegmentId or a custom segment.