Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Adding GA code if multiple tracking objects are there


Hi,
I can add GA code to my video setup like this.. If I have a single tracker object (i.e.auto).
var playerInstance = jwplayer("myElement");
playerInstance.setup({
file: "/uploads/example.mp4",
image: "/uploads/example.jpg",
ga: {
idstring: "title",
label: "mediaid"
}
});

But how can I add this if I have 2 tracker objects? The event is firing only for auto object. Please help how to add it for other object also.

3 Community Answers

Todd

JW Player Support Agent  
2 rated :

I found a code example for how to do this on Google’s web site at https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers#working_with_multiple_trackers

ga('create', 'UA-xxxxxxx-1', 'auto');
ga('create', 'UA-xxxxxx-1', 'auto', {'name': 'newTracker'});  // Second GA account tracker as documented by Google
ga('send', 'pageview');
ga('newTracker.send', 'pageview'); // Send page view for new tracker.
  

Our player will use the ga: {} block in your code to send events to the first tracker listed. You can then use custom API events to send individual pings to the second tracker:

jwplayer().onComplete(function(){
	ga('newTracker.send', 'event', 'JW Player Video Completes', jwplayer().getPlaylistItem().title, document.URL);
});

jwplayer().onFullscreen(function(){
	if (jwplayer().getFullscreen() == true) {
		ga('newTracker.send', document.URL, jwplayer().getPlaylistItem().title, 'Fullscreen: True');
	}
});

Sruthi N

User  
0 rated :

Hi Todd,
Thanks a lot. The above solution worked fine. Events are firing now for both trackers.

We want to play videos in http://sites.tcs.com/sibos-2016/success-stories/ page to open in lightbox.
Tried this with different plugins but not successful. Looking forward for any help. Thank you

Todd

JW Player Support Agent  
0 rated :

My suggestion for lightboxes is to do the following:

1) Load the player on the page as soon as the page loads with the player height and width both set to 0
2) In the function that gets called when the viewer launches the lightbox, call jwplayer().resize(‘width’,‘height’) and jwplayer().play()
3) In the function that gets called with the lightbox is closed, call jwplayer().pause(true) and jwplayer().resize(‘0’,‘0’) to hide the player again.

This question has received the maximum number of answers.