Tagged: x
-
AuthorPosts
-
September 6, 2016 at 6:55 pm #1163639
Hi,
I have a video that is triggered by a play button in one of my revolution sliders.
I want to track when people click on the play button in Google Analytics with Event Tracking. I have the following code for event tracking, but can’t figure out where to add it. Is this the right way to do it?
onclick=“_gap.push([‘_trackEvent’,’videoplay’,’playvid’,’fixvid’]);"
Any help would be greatly appreciated. Thanks so much! –
September 6, 2016 at 6:56 pm #1163641This reply has been marked as private.September 7, 2016 at 1:48 am #1164029Hi there,
Please check this link : http://www.wpbeginner.com/wp-tutorials/how-to-add-google-analytics-event-tracking-in-wordpress/
Hope it helps.
September 7, 2016 at 12:22 pm #1164802This reply has been marked as private.September 7, 2016 at 7:53 pm #1165503This reply has been marked as private.September 7, 2016 at 8:13 pm #1165531Amazing! Thank you so much!
The event is now showing up in analytics. However, there is a problem. Adding this class has removed the lightbox styling. Now, when you press the play button, you are taken to a new page (http://treehouserecovery.com/wp-content/uploads/2016/08/Healthy2.mp4?autoplay=1) instead of the lightbox.
I have disabled the class, because the page is live. Attached is an image of what it looks like before and after adding the class. Any ideas how to avoid this change? Thanks again!
September 8, 2016 at 1:25 am #1165889Hello There,
Please update your shortcode and use this instead:
[image src="http://thrcontent.com/wp-content/uploads/2016/04/play-btn-1.png" link="true" class="track-video-clicks" href="http://treehouserecovery.com/wp-content/uploads/2016/08/Healthy2.mp4?autoplay=1" lightbox_video="true"] [lightbox selector=".lightbox-video"]
And then update the JS code as well;
jQuery( '.track-video-clicks' ).on('click', function() { _gap.push(['_trackEvent','videoplay','playvid','fixvid']); } );
Please let us know if this works out for you.
September 8, 2016 at 10:17 am #1166530This reply has been marked as private.September 8, 2016 at 6:59 pm #1167179Hi there,
It doesn’t remove styling, it loads the video on the same page. It’s like clicking a link and that replaces the page you’re currently viewing.
Please change it to this
[image src="http://thrcontent.com/wp-content/uploads/2016/04/play-btn-1.png" link="true" class="track-video-clicks" href="http://treehouserecovery.com/wp-content/uploads/2016/08/Healthy2.mp4?autoplay=1" lightbox_video="true"] [lightbox selector=".track-video-clicks"]
Selector should always match.
Thanks!
September 8, 2016 at 7:08 pm #1167189This reply has been marked as private.September 8, 2016 at 7:09 pm #1167191Attached is the screenshot.
September 9, 2016 at 2:03 am #1167622This reply has been marked as private.September 9, 2016 at 12:51 pm #1168331This reply has been marked as private.September 9, 2016 at 11:08 pm #1168908Hi there,
I see, it’s because of this
jQuery( '.track-video-clicks' ).on('click', function() { _gap.push(['_trackEvent','videoplay','playvid','fixvid']); } );
That code is okay, but, this assumes that you already have the google tracking library installed. It’s failing and affecting your lightbox since it’s calling for _gap that doesn’t exist. You can’t just use it anywhere, you should install the tracking library to where _gaq is dependent. It’s a form embed codes that you’ll need to add to your site https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gaq
It’s should be _gaq and not _gap, and you should follow the embed procedure according to your analytics setup.
How about this,
jQuery( '.track-video-clicks' ).on('click', function() { ga('send', 'event', 'Videos', 'play', 'fixvid'); } );
It correctly matches your currently embedded analytics ga().
Hope this helps.
September 10, 2016 at 1:21 pm #1169424Thank you so much!
That code fixed the lightbox issue! However, now the event is not registering in Analytics. I used the ga(), which you said matches my embedded analytics. Any idea what could be wrong? Again, thank you so much for all of your help! It is GREATLY appreciated! –
B
-
AuthorPosts