开发者

twitter: share link with parameters

I have a share button on my site.

But I need to share link with parameters, and each time parameters will be different (I need to track us开发者_如何学Cer who is sharing, etc.)

For example need to share link like http://mySite.com/page?userId=111&someParam=222

I can share this well, but how can I force count to work correct?

if I set

data-url="http://mySite.com/page?userId=111&someParam=222"

data-counturl="http://mySite.com/page/"

I am getting count 0 always. How to get this work?


From http://dev.twitter.com/pages/tweet_button,

"The count box shows how many times the URL has been Tweeted."

Your problem is you simply have the url and counturl mixed up. Change url to the short one, for display purposes - that's the one people will see. Use the counturl for the one with all the parameters, to ensure they go to the right place with the parameters intact.

I suspect the reason your count kept showing zero tweets is because you have a different (unique) url as your primary url each time it is tweeted, so each tweet is the first time that url (including its parameters) was shared.


Twitter now lets you send the url through data attributes. This works perfectly for me and should work for you out of the box!

The button (check out data-url):

<a href="javascript:;" class="twitter-share-button" data-lang="en" data-text="check out link b" data-url="http://www.lyricvideos.org/tracks?videoURL=SX05JZ4FisE">Tweet</a>

The twitter javascript snippet (from https://dev.twitter.com/docs/tweet-button)

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜