Twitter share button tweet intent retrieving the data-url


I have multiple twitter share buttons on a page, I want to identify which button was used to do a tweet by using the data-url property so i can record the tweet counts.I am using the twitter intents. How can i get the page url that the tweet refers to? This must be a common requirement.

    <a href="" class="twitter-share-button" data-url="" data-lang="ja" data-counturl="">ツイート</a>

    twttr.ready(function (twttr) {
      'tweet', function (event) {



That object tells you the target DOM event that got interacted with. You can then leverage the DOM model to read attributes that you’ve applied to that original HREF, such as data-url or data-counturl or an arbitrary attribute you may have added yourself.


The target is an iframe how would i get those properties, do you have an example? I can get the “src” tag and parse it but it would be better to take it directly.
This is how im doing it now , maybe a bit brittle.“url=(.*?)&”)[1]


Same here. the event object is empty, except for the “type” attribute which is set to “tweet”. This may be caused by the button being in an iframe.

Anyone knows a solution for this issue?