citcit / autoembed

Automatically exported from code.google.com/p/autoembed
GNU Lesser General Public License v3.0
0 stars 0 forks source link

onClick stat tracking #34

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
A quick test reveals that the following code works:

{{{
<object onClick="alert('hi');" 
}}}

So this means, that via javascript, one could track the number of times an 
embedded video is clicked.

The question then is, how can this functionality (passing parameters into 
an onClick) be implemented into AutoEmbed in a nice generic/flexible way?

The goal here would be to fire off a request via javascript to a given url 
(basically to ping it) when the video is clicked.  However this would have 
to be done without any AJAX libraries.

Original issue reported on code.google.com by jhi...@gmail.com on 11 Feb 2009 at 10:51

GoogleCodeExporter commented 8 years ago
To avoid having the workaround AJAX library dependencies, perhaps the more 
generic 
solution to to somehow be able to pass an addition <object> attribute (such as 
onClick):

{{{
$AE->addObjectAttribute('onclick'=>"alert('hi')");
}}}

Original comment by jhi...@gmail.com on 11 Feb 2009 at 11:01

GoogleCodeExporter commented 8 years ago

Original comment by phpu...@gmail.com on 12 Feb 2009 at 2:22

GoogleCodeExporter commented 8 years ago

Original comment by phpu...@gmail.com on 12 Feb 2009 at 3:18

GoogleCodeExporter commented 8 years ago
added setObjectAttrib.

Will be in release 1.3

Original comment by phpu...@gmail.com on 13 Feb 2009 at 9:03

GoogleCodeExporter commented 8 years ago
I've discovered that the below can work _without the need to have AE handle the 
extra 
attribute_:

Wrap the embed output in a div with a class name
{{{
<div class="embedded"><?=$AE->getEmbedCode();?></div>
}}}

Then use Javascript to observe any clicks to the embedded object:

{{{
$$('div.embedded').each(function(e) {
        e.firstDescendant().observe('click', function() {
                alert('This video has been clicked.');
        });
});
}}}

Original comment by jhi...@gmail.com on 20 Feb 2009 at 6:51

GoogleCodeExporter commented 8 years ago
oh nice... I think this is still a useful feature.  It could be used to add a 
css
class to the embedded object or give it a specific id for manipulation via 
javascript..

and it makes the code look nicer ;)

Original comment by phpu...@gmail.com on 20 Feb 2009 at 5:05

GoogleCodeExporter commented 8 years ago

Original comment by jhi...@gmail.com on 19 Aug 2009 at 4:22