最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to track Tweet Button clicks? - Stack Overflow

programmeradmin1浏览0评论

I want to track tweet button clicks via Google Analytics, but tweet button is an iframe with content from another domain. Is there some tricks to add callbacks for tweet button click?

I want to track tweet button clicks via Google Analytics, but tweet button is an iframe with content from another domain. Is there some tricks to add callbacks for tweet button click?

Share Improve this question edited Nov 5, 2010 at 0:50 Oleksandr Skrypnyk asked Nov 4, 2010 at 0:44 Oleksandr SkrypnykOleksandr Skrypnyk 2,8201 gold badge23 silver badges26 bronze badges 3
  • Are you looking to track clicks as a proxy for actual tweets? Because its actually easier to track that count than to track what you're trying to do. – Yahel Commented Nov 4, 2010 at 3:00
  • 2 I need a full statistics for clicks in Google Analytics and Tweet Button isn't an exception. Facebook Like button have "FB.Event.subscribe" function with "edge.create" event. Anything like this for Twitter? – Oleksandr Skrypnyk Commented Nov 4, 2010 at 9:27
  • Share! :) I am looking for a way to do the same thing. – marko Commented Feb 9, 2011 at 16:49
Add a comment  | 

5 Answers 5

Reset to default 1

Or.. u can simply add event to your div and wait when this div well be clicked, like a:

<div class="clickMe">
   //twitter button there
</div>
<script>
$('clickMe').click(function(){
    //my awesome  code there
})
</script>

Sure, if you need only click, not callback.

<a style="float:left;position: relative;display: inline-block" target="_blank" href="//twitter.com/intent/tweet?url=http%3A%2F%2Ftechiessolution.com%2Fcss&amp;count=none&amp;source=tweetbutton&amp;text=testing%20Testing%20123%20Title&amp;original_referer=techiessolution.com">Tweet</a>

if (typeof twttr === "undefined") {
  $.getScript("//platform.twitter.com/widgets.js", function () {
    function handleTweetEvent(event) {
      if (event) {
        console.log(event['target']);
      }
    }
    twttr.events.bind("tweet", handleTweetEvent);
  });
}

What about:

twttr.events.bind('click', function(e){
    // Send GA event
    console.log(e);
});

try this

Tracking clicks on social buttons with Google Analytics

http://www.conversionworks.co.uk/blog/2013/05/16/tracking-clicks-on-social-buttons-with-google-analytics/

One thought is to generate a UTM'd link for the Twitter button href, then add back into iFrame source page as the href source. This will provide visibility into the click/session/user data on your Google Analytics tracking

To do this, first copy the original hyperlink and use as the source for building the link using the Google link builder. Once generated, come back into the iframe source page and add the new UTM'd link as the href source.

发布评论

评论列表(0)

  1. 暂无评论