YouTube is one of the most powerful social media marketing platforms used by businesses around the world to reach and engage customers. Creating a custom analytics dashboard is often required to monitor your subscribers’ engagement with the content in your channel. Let’s see how to build a simple analytics dashboard to show the key metrics of your YouTube channel all in one place.
Google offers two different types of APIs that allow you gather the essential information from your channel:
The YouTube Reporting and Analytics APIs let you retrieve YouTube Analytics data to automate complex reporting tasks, build custom dashboards, and more. The YouTube Data API helps you search for videos matching specific search terms, topics, locations, and publication dates.
Syncfusion Dashboards support both types of API for building your custom dashboards. To build dashboards from an analytics API, use the ‘Google Analytics’ connection in the data connections wizard. This connection extracts only the essential information from the response and ignores the other metadata.
The dedicated YouTube connection lets you connect to the Data API.
Building the Dashboard
Using the Analytics API, we are about to build a simple dashboard with key metrics, as shown in the following image.
Building the API
To start with, let’s build the required query using the Reporting API. Please refer to this documentation link to learn more about the report query.
The following API is used to fetch YouTube reports.
The API accepts several parameters that can be configured. Please refer to the previous link for the complete details of optional and required parameters. The following table explains how to include the mandatory parameters in the API query.
|ids||Identifies the YouTube channel or content owner for which you are retrieving YouTube Analytics data.
|metrics||A comma-separated list of YouTube Analytics metrics, such as views, likes, or dislikes. Refer to this page on reporting for the complete list of metrics available.
Choose the list of metrics required and add the parameters in the query.
|startDate||The start date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.|
|endDate||The end date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.|
Also, optional parameters, such as dimensions, filters, and currency, can be added if you need to narrow down the report to a specific criterion.
Dimensions are comma-separated lists of YouTube Analytics dimensions, such as video, ageGroup, or gender. The Dimensions document contains definitions for all the dimensions. Since our dashboard is going to be built upon the time series, the ‘day’ dimension can be used.
The final API query is built, as shown in the following.
Creating a data source
Secondly, let’s use this API and start building our dashboard.
In your dashboard’s home page, click the New Dashboard menu and select the Blank Dashboard option. In the dashboard designer application, open the data connection wizard in the right panel and choose New Data Source.
Choose Google Analytics from the list of connections and authenticate with your Google account.
Once authorized, add the URL in the connection wizard and choose your refresh time interval.
In the preview pane, check your results and click Connect. Eventually, the data source designer will open and you can drag your table to the design canvas. Since the response contains all the data in string format by default, modify the data type of the fields. Modify the day field to Date and other metrics to Integer.
Finally, provide a name for your data source and click Save.
You can see the prepared data source in the data sources list.
First, let’s configure the cards to show key metrics. Drag the cards to the design canvas and start building the dashboard. Click the Widget Settings icon in the card and add the required metrics to the Actual Value column. Modify the title and properties as required.
Similarly, configure the other card widgets with the required key metrics to be displayed.
Likewise, let’s configure a spline chart to show the total views by date. Drag a spline chart to the design canvas and configure it by adding the day field to the columns section and the views field to the values section. Modify the aggregation of the day field to show the data by date.
Modify the other properties and widget titles to customize the visualization.
Similarly, add a column chart to show the details of subscribers and unsubscribers by date. Configure the widget by dragging the day field to the columns and the subscribersgained and subscribersLost fields to the values.
Add another column chart to show the average view duration, as shown in the following.
Finally, let’s add a visualization to show the total views by geographic location. Create a new data source with the country dimension to show the views by country. The API will look like the following.
Add a choropleth map to the dashboard and configure it by dragging the country field to the shape section and the views field to the values section. Since the country column contains the country code, open the properties section and choose iso_3166_2 in the column option.
Finally, the dashboard preparation is complete. You can save the dashboard, share it, and collaborate with other users in the application. The data in the dashboard refreshes continuously based on the chosen time interval, helping you keep track of the latest updates. You can also combine your YouTube data with the Google Analytics data and analyze your channel the same way you would analyze your website. As a result, you can get more insights on top videos, top converting geographies, top referring traffic channels, and more.
In conclusion, we hope this blog post provided you needed information on how to retrieve the analytics data for your YouTube channel and build dashboards using it. We hope you enjoyed it and stay tuned to read upcoming posts on how to build interactive business dashboards.