Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8946199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:26:54+00:00 2026-06-15T12:26:54+00:00

I’m trying to setup GA Event Tracking on my site for an IFRAME Vimeo

  • 0

I’m trying to setup GA Event Tracking on my site for an IFRAME Vimeo Video embed. However, I can’t figure out where/how the tracking object should be placed in my IFRAME code.

Here’s my IFRAME embed code:

<iframe src="http://player.vimeo.com/video/51447433" width="500" 
  height="281"frameborder="0" webkitAllowFullScreen 
  mozallowfullscreen allowFullScreen></iframe>

Here’s what I think the GA Event Tracking code should look like:

<a href="#" onClick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'Title']);">Play</a>

Where does this go in my embed code? Can somebody show me how this should look/work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:26:55+00:00Added an answer on June 15, 2026 at 12:26 pm

    You need to use the player API because you can’t inject code inside an iframe on a third party domain like that.

    Based on the docs provided for the player API t should look something like this.

    Working Example

    <html>
    <head>
      <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXXX-1']);
      _gaq.push(['_trackPageview']);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    
    </script>
    <script>
    var f = document.getElementsByTagName('iframe')[0],
        url = f.src.split('?')[0];
    
    // Listen for messages from the player
    if (window.addEventListener){
        window.addEventListener('message', onMessageReceived, false);
    }
    else {
        window.attachEvent('onmessage', onMessageReceived, false);
    }
    
    // Handle messages received from the player
    function onMessageReceived(e) {
        var data = JSON.parse(e.data);
    
        switch (data.event) {
            case 'ready':
                onReady();
                break;
    
            case 'play':
                onPlay();
                break;
    
            case 'finish':
                onFinish();
                break;
        }
    }
    
    // Helper function for sending a message to the player
    function post(action, value) {
        var data = { method: action };
    
        if (value) {
            data.value = value;
        }
    
        f.contentWindow.postMessage(JSON.stringify(data), url);
    }
    
    function onReady() {
        post('addEventListener', 'finish');
        post('addEventListener', 'play');
    }
    
    
    function onFinish() {
        _gaq.push(['_trackEvent', 'Vimeo Video', 'finish', url]);
    }
    
    function onPlay() {
        _gaq.push(['_trackEvent', 'Vimeo Video', 'play', url]);
    }
    </script>
    </head>
    <body>
      <iframe src="http://player.vimeo.com/video/27855315?api=1" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    </body>
    </html>
    

    The code above can be simplified a by using the Vimeo Mogaloop api that abstracts the Message Passing API for you, at the cost of loading the Javascript with the library.

    Plugins Ready to use

    Note that the above code will only work as an example and if you have multiple videos on a page it can be harder to get it right. Alternatively you can also use the GAS (I’m the main developer there) library that has a plugin for tracking Vimeo Video.

    Warning about compatibility

    Note the Warning about compatibility, I guess if you insert the player using the flash method you can get a wider range of browsers supported but kill the player completely for iOS devices:

    With the Universal Embed Code, the only way to interact with the
    player is by using window.postMessage. postMessage is a relatively new
    development, so it’s only available in Internet Explorer 8+, Firefox
    3+, Safari 4+, Chrome, and Opera 9+.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.