Javascript events return undefined



I try to get some information about the twitter user when he clicks on tweet button (like user_id or screen_name). For test purpose I add a simple tweet button on an html page and some javascript code as I described below :

This is the code to get information on tweet event :

<script type="text/javascript">
  twttr.ready(function (twttr) {
    function handleTweetEvent(event){
      if ( {
        alert(' '' '' ';
    }'tweet', handleTweetEvent);

But my javascript alert renders : “undefined undefined undefined undefined”.

My tweet button looks like this :

<a href="" class="twitter-share-button">Tweet</a>

And according to this part of the documentation :, I added this snippet in the head section of my html page :

<script type="text/javascript" charset="utf-8">
  window.twttr = (function (d,s,id) {
    var t, js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return; js=d.createElement(s);;
    js.src="//"; fjs.parentNode.insertBefore(js, fjs);
    return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
  }(document, "script", "twitter-wjs"));

I don’t understand why all attributes are “undefined” ? Do you have an idea about this problem?
Thanks a lot for your help.


User information is not available from the Tweet web intent as it would identify the user who is currently on your site. Tweet Button events mostly pertain to the DOM element clicked and whether the action was completed or not.


Thanks for your answer. Is there another way to know the user_id when a tweet is complete? I can imagine when a tweet is complete the user is identified on twitter plateform, therefore may be we can get this information?


It’s kind of missing on purpose – the user doesn’t have a relationship (modeled by an OAuth connection in our platform) with the site, so doesn’t have the opportunity to be asked whether it’s all right to share their information with you.

For public tweets, you can use the Search API or Streaming API to monitor tweets mentioning your URLs and domains.


You’re completely right. I perform some test on a same html page of the same domain … so … I mixed up client side and server side.
Again, thanks for your answer.