We all know that getting information out via Twitter is helpful to your brand or company, but what if you want to have your website or blog readers do it for you? Or perhaps you want to get a standard message out or include a keyword or two through the use of hashtags (#).
NOTE: As of May 2011, this method no longer works! Please read my NEW post on the new way here.
The process for doing this is very easy, however I learned a little trick that you can use, especially if you want to use hashtags (which I solve at the end of this post).
Simple Link
The context is very simple. Let’s say the message you want to post is:
“I learned how to pre-populate Twitter statuses at: https://www.hightechdad.com Thanks @hightechdad!”
All that you need to put in for your link is:
http://twitter.com/home?status=I learned how to pre-populate Twitter statuses at: https://www.hightechdad.com Thanks @hightechdad!
Try it by clicking this link –> http://twitter.com/home?status=I learned how to pre-populate Twitter statuses at: https://www.hightechdad.com Thanks @hightechdad!
Linked Text
If you want to make it a bit more elegant, you can put it into link tag and simply link a word or set of words:
<a href="http://twitter.com/home?status=I learned how to pre-populate Twitter statuses at: https://www.hightechdad.com Thanks @hightechdad!">TWEET THIS</a>
Try it by clicking this link –> TWEET THIS
Issues with Hashtags
Hashtags are important in many Twitter messages because that give users the ability to group similar messages together. Let’s say that you are attending “XYZ Expo” and you heard something interesting that you wanted to share with your Twitter followers. By adding a hashing and a keyword like #xyzExpo, you can start “tagging your tweets.” That way, when people click on your hashtag, it will show all tweets that have the same hashtag. It’s a great way to consolidate like tweets and Twitterers.
Normally, in the tweet, you would simply put in the “#” (hashtag symbol). However, when you want to put it into a link like the one listed above, you run into issues. This is because the “#” is used within URLs as an anchor tag. For example, if you want to jump to a particular area within a page, you would add a “#” to the end of the page name as well as tag that section within the page for that anchor link. Say that you have a section called “Details” and you anchor your page there, the link would be “somepage.htm#details”. This is great for in-page navigation but poses problems with the Twitter status linking. If you only include the hashtag, the Twitter server will give you an error, thinking it is looking for a particular anchor on a page that doesn’t exist.
Unfortunately, you can’t use a special “&xxx;” type of code for the # symbol (the way you can with “&” which is “&”) because the translation for the “#” actually CONTAINS the “#” symbol (the special HTML character for a hashtag is “#”which contains a # so it won’t work).
Solution
So, how can you make hashtags work in a pre-populated Twitter status update? Easy, you use a different type of character. And actually, you should do the same for spaces.
The characters:
- space = %20
- hashtag = %23
Let’s say you want to pre-populate the message:
“I learned how to pre-populate Twitter statuses with hashtags at: https://www.hightechdad.com Thanks @hightechdad! #cool”
The html code would look like this:
<a href="http://twitter.com/home?status=I%20learned%20how%20to%20pre-populate%20Twitter%20statuses%20with%20hashtags%20at:%20https://www.hightechdad.com%20Thanks%20@hightechdad!%20%23cool">TWEET THIS</a>
Try it by clicking this link –> TWEET THIS
You can also, I believe, eliminate all of the %20’s from your message and simply use the %23 for the hashtag. So, your code would look like this:
<a href="http://twitter.com/home?status=I learned how to pre-populate Twitter statuses with hashtags at: https://www.hightechdad.com Thanks @hightechdad! %23cool">TWEET THIS</a>
Try it by clicking this link –> TWEET THIS
Do note that the user must be logged in or log in to make this work. Obviously they do need to have a Twitter account. They also do have the ability to change the context of the tweet as all that this does is pre-populate the status field on Twitter’s site. I hope you found this useful. It can help your audience to get out tweets easily directly from your site.
HTD says: Twitter is a very useful communication tool. Enabling your users to get your message out easily is critical.
18 Responses
Wow! This is a very cool trick!
Thanks for sharing! :)
Yeah, it is actually pretty simple. The hashtag was really annoying me so I wanted to figure out a solution. Glad to help!
excellent, i will be using that right away. i see you are the father of 3 girls, so wonderful. I am a father of 4 girls.
embedded twitter form?
It should be noted that you can not use www in the URL. Twitter will not convert the %20 and %23 into the right html characters. unless you strictly use http://twitter.com
for example: http://www.twitter.com/home?status=I%20learned%…
Thanks for pointing that out! WWW is just so old anyway!
It should be noted that you can not use www in the URL. Twitter will not convert the %20 and %23 into the right html characters. unless you strictly use http://twitter.com
for example: http://www.twitter.com/home?status=I%20learned%…
Thanks for pointing that out! WWW is just so old anyway!
Holy crap! That is cool.
If you are not logged into twitter and you click on one of these links you will be prompted to login. Once you login your prepopulated tweet will be broken if you used %23 for a hashtag.
I don't know of a fix but I am looking for one.
Thanks for the info, I thought that I had tested that. I did test a few times with logged out scenarios. Perhaps I will come up with an answer (or you will).
The sky parted and the angels sang…Aaaaahhhhh!
Thank you!
This is truly a great asset. Makes life so much easier especially during giveaways. Thanks for sharing this
Thank you thank you for posting this!!!
Thanks this came in handy today.
That helped so much! thanks!
Yes, you landed on this page searching for how to do this. I am here from 2022.
It looks different now. Try this:
https://twitter.com/compose/tweet?text=Here%20Is%20Some%20Text
You are welcome.
Thanks, Zachary – yeah, my How-to article was from 2009 so a LOT has changed since the original post.