The “Tweet” button that appears in some web pages can be used to post a tweet that includes the URL of the page.
How does it work
Some web pages show a “Tweet” button, often grouped together with buttons of other social networks, such as Facebook, LinkedIn, etc:
Clicking on the Tweet button, a pop-up is opened to share the link to the page being visited. If we are not logged int to Twitter at that time, the pop-up window includes the username and password fields to login to Twitter with an existing user, or to register a new user if we haven’t one yet.
At the top of the pop up, the text field used to compose the tweet is pre-filled with the title and URL of the page. We can edit this field as we see fit, keeping the length of the message below the 140 character limit. In the lower right of the field, a counter shows the number of characters left. Finally, click on “Tweet” to post the message.
Optionally, we can visit our twitter.com profile to verify that the Tweet has been correctly sent.
How to add the Tweet button to the pages in our site
- First, go to https://about.twitter.com/resources/buttons, where the button design tool can be found. The window displayed offers to choose one of four types of button:
- After choosing “Share a link”, a form is displayed. In this form, we can configure the desired look and functionality of this type of button:
- Copy the HTML code from the text field at the right side of the form, and paste it in the HTML code of the pages in our site, wherever we want it to appear:
<a href="https://twitter.com/share" class="twitter-share-button"
}(document, 'script', 'twitter-wjs');
Note: Optionally, in the form above we can choose to show a counter to the right of the button, that will display the number of tweets and retweets done.