How to add Facebook Like and Twitter Follow button on your Magento Store?

How to add Facebook Like and Twitter Follow button on your Magento Store

The past decade has witnessed an immense growth in the social media popularity. The best thing happened when social media started helping businesses to establish a solid web presence, generate strong leads, and increase website traffic through an effective marketing strategy.

With social media today you can reach to your first-time visitors as well as the repeat customers in multiple ways and showcase the best your business has to offer. A well developed and organized social networking strategy is very crucial when you depend on social media for marketing, lead generation and much more.

Different forms of social media engagement provide multiple ways to improve the user experience and brand image of your business. Features like social login, Facebook login, click to tweet, share on Facebook, follow on Twitter are some examples of how social media can be integrated on your site itself.

Today we are going to discuss on such integration that you can do on your Magento store- how to add the Facebook’s “Like button” and Twitter’s “Follow button” on your Magento store? This addition will help you to improve the social media visibility of your Magento pages by allowing users to Like or Follow your brand.

Get Facebook Like button code

Let’s start with Facebook like button then we will add the Twitter “Follow” button. So, for adding the Facebook Like button first visit the Facebook’s developer site and navigate to the following URL.

You will find the following form asking some details to be filled in.

Like Button Configurator

  • Enter your website page URL or your Facebook social page’s URL in the “URL to Like Section”
  • Enter the width of the button that you wish.
  • Select the button layout and hit the Get Code button below.

If you also want to show the Facebook “Share” button by the side of Like button, you can check the check-box that says “include Share Button”.  Keep the code screen as it is, and proceed to the next step.

Get the Twitter Follow button code

To get the Twitter’s Share button code you need to first visit the following Twitter URL.

You will see the following page:

Asked to embed twitter URL for like code

Here, enter your Twitter page URL and follow the on-screen instructions to get the Share button code.

Scroll down to find the following interface and click as shown in the image below:

interface to get twitter buttonsNext, you will see a pop-up. Here you need to click on the “Follow Button” option as shown in the image below:

Interface Ask for Twitter Button Choice

The next interface will ask you to enter either your Twitter Page URL or your Twitter Username. Enter anyone and click Preview. You will get the code.

Asked for Twitter Page URL or User Name

Add social buttons to your Magento store

Now we have the Facebook Like button and Twitter Share button code. I am going to add these social buttons on my Magento Product Page. So I need to edit the following file from website’s FTP.


Open the view.phtml file in any of the editors you like to use. I am using Netbeans. You can use any text editor like notepad, Notepad++, etc.

You have the option to add these social buttons on any position on the page. However, I have chosen the space below the Product title on the page.

So, to add the social buttons on the space below the Product name on your Magento page, search for the following code in the view.phtml file.

<div class="product-name">     
<span class="h1"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></span> 
<div class="price-info">     
<?php echo $this->getPriceHtml($_product); ?>     
<?php echo $this->getChildHtml('bundle_prices') ?>     
<?php echo $this->getTierPriceHtml() ?> 

After this code, add a new <div> with class=”social-info”. Inside this new <div>, add the codes that you have got from Facebook and Twitter respectively. The code would look something like this:

<div class="product-name">

<span class="h1"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></span>


<div class="price-info">

<?php echo $this->getPriceHtml($_product); ?>

<?php echo $this->getChildHtml('bundle_prices') ?>

<?php echo $this->getTierPriceHtml() ?>


<!-- Social Buttons -->

<div class=”social-info”>

<!-- Code for Twitter Follow button -->

<a href="" class="twitter-follow-button" data-show-count="false">Follow @knowbandplugin</a><script async src="//" charset="utf-8"></script>

<!-- Code for Facebook Like button -->

<div id="fb-root"></div>

<script>(function(d, s, id) {

var js, fjs = d.getElementsByTagName(s)[0];

if (d.getElementById(id)) return;

js = d.createElement(s); = id;

js.src =

"//";   fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div> </div>

When done with the code addition, Save the file. Clear the Cache Magento cache and navigate to your product page to see if you are successful in adding the social buttons to your Magento store.   It would look something like this if added correctly:

Default Welcome MSG!

To conclude

Social media has become an inseparable organ of the businesses thriving because of it. Whether it is through social login plugins, Social advertisement, or social sharing, social media is helping businesses in uncountable ways. Which kind of social media options do you use in your business? Do let us know in the comments.

Want to learn more? Read our posts on:

How to start a PrestaShop Twitter login on your PrestaShop store?

Setting up the Google Login for PrestaShop sites

You Might Also Like:

Joe Parker

We boast of the best in the industry plugins for eCommerce systems and has years of experience working with eCommerce websites. We provide best plugins for platforms like - Magento, Prestashop, OpenCart and Shopify . We also provide custom module development and customization services for the website and modules..

Leave a Reply

Your email address will not be published. Required fields are marked *