I
I
Igor2017-05-19 17:05:20
JavaScript
Igor, 2017-05-19 17:05:20

How to put google analytics target on iframe?

Hello.
You need to set goals for Yandex metrics (it turned out) and Google Analytics for the youtube video in the iframe.
I do it through the iframeTracker plugin
https://github.com/vincepare/iframeTracker-jquery/...

for Yandex it turned out, for Google I can’t understand what needs to be done
I did this:

in the header of the site

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="js/jquery.iframetracker.js"></script>
   <script>     
jQuery(document).ready(function($){
    $('.youtubevideo iframe').iframeTracker({
        blurCallback: function(){
            yaCounterXXXXXXX.reachGoal('videoclick'); 
            alert('тест');
        }
    });
});
           </script>

and in the body of the page
<div class="youtubevideo" itemprop="embedHTML"><iframe width="560" height="315"                
      src="ссылка на видео" frameborder="0" allowfullscreen></iframe></div>


actually everything. goal earned

about google analytics found this solution
context.tips/analitika/otslezhivaem-kliki-po-ifram...

added
jQuery(document).ready(function($){
    $('.youtubevideo iframe').iframeTracker({
        blurCallback: function(){
            yaCounterXXXXXXX.reachGoal('videoclick'); 
dataLayer.push({
          'event':'videoyoutube', 
          'eventCategory':'video', 
          'eventAction':'clickvideo', 
          'eventLabel':'videoevent'
        }); 

        }
    });
});

and nothing.. videoyoutube,video,clickvideo and video - the name of the goal fields from googleanalytics
I understand that this is not enough.

What is wrong or what else needs to be done to transfer data to analytics?
Or is there another way?

PS js I know at hello word level, I would be grateful if you take this into account when explaining

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tyzberd, 2017-05-19
@onedeadyankee

try like this

ga('send', {
  hitType: 'event',
  eventCategory: 'Videos',
  eventAction: 'play',
  eventLabel: 'Fall Campaign'
});

https://developers.google.com/analytics/devguides/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question