Tweet Button: How to NOT Include Referring URL and via @username in Tweet?


#1

See title/question. Nothing more to add.

Thanks, Bryan


#2

You can explicitly specify the URL you would like to share using the “data-url” parameter, and by omitting the “data-via” param, we will not append the “via @username” in the tweet text.


#3

Hey, thanks. Were you trying to post code to show me, if so… you might have enclosed it with the wrong tags, can’t see it.

  1. Specifying the URL defeats the purpose of wanting to suppress it altogether.

  2. In my testing, omitting the data-via doesn’t matter. It still automatically appends the username of the logged in user. And since you have to be logged in to Tweet, this is unavoidable.

As a possible workaround I’ve tried placing arbitrary text for the data-url like false for example which works in appearance, but causes wonkiness behind the scenes for the button. Also, placed # or   for data-url which kind of half works.

Either way, there’s really not an ideal solution to create a Tweet button with just the Tweet text outside of asking people to copy/paste a Tweet which of course is no good in our instant gratification culture.

So I guess we can chalk this up as a suggestion for future development? Being able to add false to hide parts of the Tweet we don’t want included.

Also, if you have a minute, the latest Twitter update rendered this button broken (the only thing that’s special about it is that it’s a PDF URL):

https://dev.twitter.com/discussions/4167

Thanks, Bryan


#4

Just to be clear, are you trying to create a tweet button that does not share a url? (the general purpose of the current tweet button is to share URL’s on Twitter).

If you are just trying to create a button that opens a new Tweet popup, I’d suggest looking at the Twitter Tweet Web Intent: https://dev.twitter.com/docs/intents

Or, depending on your use case, you could use some of the new buttons that were just released today: https://twitter.com/buttons

I’ll take a look at your other post, and will follow up regarding that issue on that thread. Let me know if this clarifies some of the issues you brought up.


#5

That is it indeed sir, I need to be looking at intents instead of trying to put a square peg in a round hole.

Thanks, Bryan


#6

Great, glad we could help!


#7

Hi,

I’m facing the same issue using Web intents already. I’m building a link tag containing only the text parameter like this :
Tweet
My text already contains a url, a message and two hashtags. Unfortunately, the url of the current page is automatically appended to the content of my text parameter.
I would like to be able to set the whole content of the tweet myself.


#8

@leonardmessier - Twitter Web Intents do not require the class “twitter-share-button”, using that class will turn your link into a tweet button (which will include the page url). If you drop the class, but still include widgets.js, then the web intent popup will work as expect.

Let me know if this solves your issue.


#9

Yeah, you’ll have complete control, but the compromise is that you’ll need to design your own Tweet/Retweet graphic or write some CSS.

If it’s just going to be the same text over and over that you want people to Tweet you might want a Retweet button instead:

Retweet

So, just create the text and Tweet it on your Twitter profile then extract the Tweet ID from it (by right-clicking on the Tweet date and copying the ID or following the link and copying out the ID) and replace 142828511663620097 with your own.

If what you want is different you could still just apply my custom CSS to your button/link:

Tweet

See demo of the button here:

http://bryanhadaway.com/giveaway-friday-100-dollars/

I can also help you write up some different CSS if you like. The button I’ve designed so far is pretty plain Jane, how I like it. But, I’ll probably write an article on how to utilize CSS3 for feature rich buttons, gradient, shadow, inset text etc.

Thanks, Bryan


#10

Thank you both !

@chanian : removing the class definitely worked. Worth mentioning is the fact that I had to urlencode the whole content of the text parameter, otherwise it won’t work but that should be pretty obvious for anyone else than me !

@Bryan : I won’t be handling the CSS myself, but thanks for the tip !


#11
Tweet

The thing that does the trick is adding ‘?url=/’ to the default ‘https://twitter.com/share’ href. I found this by looking at the doc here:

https://dev.twitter.com/docs/tweet-button

In the ‘Properties which can be used by the Javascript Tweet Button’ section, in the table, you can see how Twitter puts a priority for each properties. For url, the first priority is the share query string, and by default it’s the HTTP Referrer. So I tought I could hack this by adding a parameter ‘url’ to the query string. But it can’t be empty, so i used ‘/’, and it seems to work.


#12

Thank you! This is awesome.


#13

This was mucho helpful, thanks!


#14