Usage
This function runs automatically, so it is not called manually. Is this incorrect?
Additional Notes
This function looks for iframe elements with a src that contains “youtube”.
Source File
Located in /assets/js/modules/video.js on line 267.
No Hooks
This function does not have any filters or actions available. Request one?nebula.youtubeTracking = function(){ nebula.once(function(){ if ( jQuery('iframe[src*="youtube"], iframe[data-src*="youtube"], .lazy-youtube').length ){ //If Youtube iframes or lazy Youtube videos exist //Note: With GA4 or GTM, the iframe_api script may already be added and if so, the onYouTubeIframeAPIReady function may have already been called! //If this happens, GA4 will "claim" those videos by making its own players and Nebula will be unable to track them //If the onYouTubeIframeAPIReady has already been called if ( typeof YT !== 'undefined' && YT.loaded ){ nebula.youtubeIframeReady(); //The API has already been loaded, so just call Nebula's ready functionality } else { //Otherwise load the JavaScript //Load the Youtube iframe API script let tag = document.createElement('script'); tag.src = 'https://www.youtube.com/iframe_api'; let firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); } } }, 'nebula youtube api'); };
Override
To override or disable this JavaScript function, simply redeclare it with the exact same function name. Remember: Some functionality is conditionally loaded via dynamic imports, so if your function is not overriding properly, try listening for a DOM event (described below).
For non-module import functions:
nebula.youtubeTracking = function(){ //Write your own code here, leave it blank, or return false. }
For dynamically imported module function overrides:
jQuery(window).on('load', function(){ nebula.youtubeTracking = function(){ //Write your own code here, leave it blank, or return false. } });
Custom Nebula DOM events do also exist, so you could also try the following if the Window Load listener does not work:
jQuery(document).on('nebula_module_loaded', function(module){ //Note that the module variable is also available to know which module specifically was imported if ( typeof nebula.youtubeTracking === 'function' ){ nebula.youtubeTracking = function(){ //Write your own code here, leave it blank, or return false. } } });