Tutorial: How To Embed Adsense For Live Streaming on Youtube

dhtmldhtml Posts: 984
edited June 2019 in PHP

The first step is to get your youtube channel verified.

After this, you should be able to connect your cam e.t.c and do live streaming.

However, in order to embed the live streaming to a website, you need to visit here : https://www.youtube.com/features.
You must have a verified adsense linked to your youtube in order to enable embedding of live streaming.

You will be required to insert your adsense code like the one below into every page on your website:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-8478545727503791",
    enable_page_level_ads: true

After your adsense has been approved and the features Live streaming and Embed live streams are enabled.

you can set the stream to unlisted or public
Go to the “Watch page” (View on watch page link (lower right) in )
Click Share -> Embed to get the embed HTML code

<iframe width="560" height="315" src="https://www.youtube.com/embed/XYZ123" frameborder="0" allowfullscreen></iframe>

Now the problem is: every time the stream stops and restarts, the ID changes.

To get a permanent URL, you need to change the link to use the Channel ID (12345 in this example):

<iframe width="560" height="315" src="https://www.youtube.com/embed/live_stream?channel=12345" frameborder="0" allowfullscreen></iframe>

Get the Channel ID from Not the User ID!

Add this into your website HTML, and open the website in anonymous browser window to check if the stream displays without error message.

Sign In or Register to comment.