RebelMouse Talk to Us
Custom YouTube Hashtag and Channel Playlists

Design your own video strategy with custom playlists

At RebelMouse, we have the ability to implement almost any idea thanks to the power of our Layout & Design Tool. One use case is the ability to easily create custom YouTube playlists based on hashtags.

For example, if your company uses the #OurCompany hashtag, you could create a custom YouTube playlist on your website that pulls in content from that stream. You can also customize the playlist so that it only pulls in videos from a certain YouTube channel, or from a single channel without a hashtag:

The key to creating a custom playlist is to use YouTube's API to pull content. Let's explore how to pull content based on a hashtag, regardless of the channel.

Query for a Playlist Based on a Hashtag

The first step is to create a JavaScript variable for the query that will pull from the YouTube API. For example:

var queryStr = '' + queryHash + '&type=video&videoCaption=any&videoDefinition=any&videoDimension=any&videoDuration=any&videoEmbeddable=any&videoLicense=any&videoSyndicated=any&videoType=any&key=' + key + '&maxResults='+maxResults;

For playlists based just on hashtags, there are three required parameters:

  • QueryHash: Your custom hashtag.
  • MaxResults: Fetch x videos, where x equals the maximum number of videos you want to pull. It can be any positive integer value.
  • Key: The API key. (This will be shared by the owner of the YouTube channel. See this guide that describes how to get an API key.)
  • ChannelId: This is an optional parameter. If it's provided in your query, it will only fetch videos from the channel ID you designate, otherwise it will fetch videos from any channel. Click here to learn how to locate a channel's ID.

Query for Playlists Based on Hashtags From a Single Channel

Here is the API query using the ChannelId parameter:' + queryHash + '&type=video&videoCaption=any&videoDefinition=any&videoDimension=any&videoDuration=any&videoEmbeddable=any&videoLicense=any&videoSyndicated=any&videoType=any&key=' + key + '&maxResults=' + maxResults + '&channelId='+ channelId;

Understanding the JavaScript Logic

Now that we have an understanding of which query strings to use when making requests to the YouTube API, let's dive into how the JavaScript logic works

The basic idea is that we use the fetch API built into modern browsers to make Ajax requests to the YouTube API. Next, it fetches a response in JSON, and then we parse it and display the response in a video format using iframes.

Here is an example of a JSON response from the YouTube API:

 "kind": "youtube#searchListResponse",
 "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/zdxYH_AS29xYgdx2YxQYxPeLj-I\"",
 "nextPageToken": "CAEQAA",
 "regionCode": "IN",
 "pageInfo": {
  "totalResults": 12,
  "resultsPerPage": 1
 "items": [
   "kind": "youtube#searchResult",
   "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/77ZWdQpKmM3r0vin9RorTTevnQc\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "iv0N7i2virY"
   "snippet": {
    "publishedAt": "2019-07-04T08:40:09.000Z",
    "channelId": "UCJv753whZjpW22UfmaJbx4Q",
    "title": "From Kurils with Love: The Expedition Trailer",
    "description": "On Monday, the 8th July, an unusual expedition is setting sails in the town of Petropavlovsk in Kamchatka. A group of filmmakers, adventurers, climbers, ...",
    "thumbnails": {
     "default": {
      "url": "",
      "width": 120,
      "height": 90
     "medium": {
      "url": "",
      "width": 320,
      "height": 180
     "high": {
      "url": "",
      "width": 480,
      "height": 360
    "channelTitle": "Tomorrow Unlocked",
    "liveBroadcastContent": "none"

Sample Code

Below are some sample codes for using JavaScript to fetch a response for videos based on a hashtag and then render them as an iframe video player:

<div class="hash-videos"></div><button id="load-more-videos" class="load-more" onclick="LoadMore()">Load More</button><style>
.hash-videos {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
.yt-iframe {
margin: 0px 10px 0px 0px;
width: 340px;
padding: 5px;
/* tablets */
@media screen and (min-width: 768px) and (max-width: 1023px) {
 .yt-iframe {
  margin: 0 auto;
  width: 50%;
  box-sizing: border-box;
  /* small devices */
@media screen and (max-width:767px) {
  .yt-iframe {
  margin: 0;
  width: 100%;
  padding: 0 0 15px 0;
.load-more {
background: black;
border: 1px solid;
padding: 10px 20px;
width: 200px;
margin: 40px auto 50px;
display: block;
font-size: 15px;
  var queryHash = ""; //"fromkurilswithlove";
  var maxResults = 6;
  var key = "AIzaSyC5PqJgz18fIBjd9Yq3eA6cmL3EfmrbL1w";
  var pageToken = "";  // Pagination Logic.
  var channelId = "UCJv753whZjpW22UfmaJbx4Q"; // TomorrowUnlocked
  function LoadMore() {
 fetch('' + queryHash + '&type=video&videoCaption=any&videoDefinition=any&videoDimension=any&videoDuration=any&videoEmbeddable=any&videoLicense=any&videoSyndicated=any&videoType=any&channelId='+ channelId +'&key=' + key + '&maxResults='+maxResults+'&pageToken='+pageToken)
      function(response) {
        if (response.status !== 200) {
          console.log('Looks like there was a problem. Status Code: ' +
        // Examine the text in the response
        response.json().then(function(data) {
    .catch(function(err) {
      console.log('Fetch Error :-S', err);
  function renderVideos(data) {
    var videosData = data.items;
    var playerFrame = document.getElementsByClassName("hash-videos")[0];
    for(var i = 0; i < videosData.length; i++) {
        /*<div class='yt-iframe'><iframe title='' type='text/html' src=' frameborder='0' allowFullScreen></iframe><div>*/
        var ytdiv = document.createElement("div");
          var ytIframe = document.createElement("iframe");
          ytIframe.setAttribute("src", "" + videosData[i].id.videoId);
        ytIframe.setAttribute("title", videosData[i].snippet.title);
        ytIframe.setAttribute("allowFullScreen", "true")
        ytIframe.setAttribute("frameborder", 0);
    //check if we have more videos else hide load more button
    if(data.nextPageToken) {
      pageToken = data.nextPageToken; //YT response gives a token for next page fetch.
    } else {
      pageToken = "";
      var x = document.getElementById("load-more-videos"); = "none";

If you have any questions or need help implementing this or any other feature — depending on the nature of the request, it may require services hours from us to complete the work — please email or talk to your account manager today.

What Is RebelMouse?
Request a Proposal
People on a train station
Rebel Insights

RebelMouse Q1 2021 Platform Updates

Speed, performance, and Core Web Vitals enhancements

Click here to read our Q2 2021 platform performance updates!

At RebelMouse, we pour our souls into making sure that our platform is always the most modern, high-performance CMS on the market. In fact, we invested over $100,000 worth of hours into our platform in Q1 2021 alone. This has resulted in updates and performance enhancements that publishers would have to pay for on their own to make happen on any other platform, such as WordPress. We're proud to be at a level of scale where we can invest this way into our platform, and we will continue to invest at this rate every quarter moving forward just as we have in the past.

Here are the major updates that we've added to the platform in Q1.

Keep reading... Show less
Interested in a Free Website Health Check?Check Your
Website's Health
Get Your Free Analysis Now
how to set up google publisher center
Rebel Insights

A Guide to Google's Publisher Center

May 2022 Update: Looking to set up Publisher Center?

Navigating critical tools for your organization on your own can be treacherous. RebelMouse has built a platform infrastructure that exceeds the digital publishing industry’s standards, while simultaneously cracking the code on Google's algorithm puzzles. Our platform is designed from the ground up to empower users of every skill level to build sites that perform well against Google’s Core Web Vitals, which means better organic reach, search returns, and visibility. In fact, Google recently featured RebelMouse on its blog to highlight how our performance optimizations nurture user loyalty and engagement. We provide the tools and information that unlock sustainable growth and revenue, and we outperform other industry leaders on site, search, and social. Let's start working together.

In late 2019, Google merged Google News Producer and Google News Publisher Center into a single tool. Officially called Publisher Center, Google has created an enhanced user experience and expanded set of functionalities that easily allow any publisher to manage content across multiple properties on Google News.

One of the many great new features Publisher Center offers is the ability to manage multiple sites simultaneously under one organization, as well as the ability to switch between more than one organization.

This makes managing many sites across multiple organizations a snap.

Keep reading... Show less
Engagement on the Rise: Why It’s Your Ticket to Loyalty
Rebel Insights

Engagement on the Rise: Why It’s Your Ticket to Loyalty

New data from Chartbeat shows engagement time is increasing despite traffic dips

Getting users to your site is only half the battle. For publishers, it’s now become more critical to focus on how long those users stay on your site — and if they ever come back. Q1 2022 data analyzed by Chartbeat found that engagement is on the rise, even though metrics like pageviews and mobile traffic experienced a decline.

Chartbeat measures engaged time by the “amount of time that readers spend actively engaging with a page — scrolling, clicking, or moving their mouse.” With this in mind, their data showed that most regions in the world registered an average of 30 seconds of engaged time on site in Q1. Readers in Latin America led the results with an average of 34.7 seconds of engaged time.

Keep reading... Show less
Build on a Better PlatformReady to See More?
Request a Proposal