Sunday, August 21, 2011

Automatically add hashtags to your tweets

Hashtags are topics or categories for your tweets. They are in a way similar to (Blogger post) labels, but for Twitter. Hashtags are made up of keywords, preceded by a hash (#) symbol.
Adding a hashtag gives your tweet a potential to be picked up by people searching for that particular hashtag. Look at the example below as I hashtagged #blogspot and #tutorials to my tweet. If you were to search for either #blogspot or #tutorials using Twitter search box, then you just might see this particular tweet, together with other tweets with the same hashtags.



twitter hashtag


Now back to beginning of the post where I said hashtags are similar to labels. If that is the case, does it not make sense to use your labels as hashtags when you tweet your post? Yes, of course….but….okay I know you hate typing in those hashtags. (That is probably one of the reasons you put a retweet button in your blog in the first place).

That’s why we’ll make it automatic. With the help of Tweetmeme retweet button, all you have to do is click, I promise :). The button supports hashtags and coupled with some Blogger code, we can convert post labels to hashtags, automatically.

(If you haven’t added the retweet button already, follow the instructions in Add retweet button (with counter) to every post and add the button now).

I. Using labels as hashtags

Now how do we do that? Simple, just insert this code after line 3 of the existing Tweetmeme button code:
1tweetmeme_hashtags = '<b:loop values='data:post.labels' var='label'><data:label.name/><b:if cond='data:label.isLast != &quot;true&quot;'/>,</b:loop>';    
Note: A multiple-word label will be converted into multiple hashtags. For example a label “Blogger tutorials” will generate two hashtags -#Blogger and #tutorials.

II. Enter hashtags manually

To add the hashtags manually, use this code instead of the code in I.
1tweetmeme_hashtags = 'myhashtag1,myhashtag2';
Each hashtag must be separated by a comma. The above code will add #myhashtag1 and #myhashtag2 to all your tweets.

Enjoy!

0 comments: