Bounteous-Inc / youtube-google-analytics

YouTube Google Analytics Embed Tracking
MIT License
232 stars 89 forks source link

Not working #2

Closed ghost closed 9 years ago

ghost commented 10 years ago

It's not working anymore, there are no console errors.

derRobert commented 10 years ago

@carlos1518 & @giorgiobeggiorasitebysite

Did you append enablejsapi=1 to the src URL? E.g.:

<iframe width="600" height="400" src="//www.youtube.com/embed/<video-id>?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
Heisem commented 10 years ago

@derRobert Never had to use that attribute before. Actually i managed to fix the code without that, seems like the the iframe api can't take control of the video iframe with the current method of custom "id" = "video id" attribute, i have not had the time to issue a pull request, i would like to know why this happened before that, because my method takes a different approach, and this is the second time that i have run into this issue.

bransinanderson commented 10 years ago

@Heisem yeah it looks like if I use a div with the video id it works. I can't target my embeeded iframe though videoArray[j]. I'm wondering what did you modify in order to target the iframe?

Heisem commented 10 years ago

@bransinanderson I couldn't target the iframe so i replaced it with a div just like you said, with the height of the iframe and 100% width.

bransinanderson commented 10 years ago

@Heisem @lunametrics I got it working.

I changed the reloadFrames variable to a value of 1.

The problem with this script is that it targets all iframes. So it tries to work it's magic on anything iframe and fails. I changed the script to target only iframes that contain the word youtube.

Around line 68.

jQuery('iframe[src*="youtube"]')

Heisem commented 10 years ago

@bransinanderson Your solution works really good, i ended up using your implementation, looks like there is a pull request for this. Thanks