Google Tag Manager & Youtube Conflict

2019-06-07 15:13发布

EDIT: the problem is no longer relevant. GTM do not affect Youtube API anymore. (In the jsFiddle demo, video informations (state, currentTime, duration) are always correct).

Calling the Google Tag Manager seems to wreck the Youtube API. Here is a fiddle demo :

Google Tag Manager & Youtube (jsfiddle)

// where thoses methods do not work anymore
player.getPlayerState();
player.getCurrentTime();
player.getDuration();

by commenting the line 16 Youtube API works again (correct state, correct currentTime / duration displayed). Since the video is still playing, it seems like the js api is disabled.

Any idea to avoid that ?

1条回答
唯我独甜
2楼-- · 2019-06-07 15:35

The GTM container you load in the fiddle has a number of heavy customizations against the YouTube API in Custom JavaScript variables. By disabling / removing those variables, the YT methods on the page should work again.

So this would be a custom scripting issue in the Custom JavaScript variables you have created in GTM, and not a native issue with GTM's built-in functionalities.

查看更多
登录 后发表回答