Twitter Handle: Why Your Ecom Store Needs One

There are currently a lot of social services that allow not only monitoring of events in any part of the world but also use their data in promotion and improvement of your business.

One of the most popular social networks in the world is Twitter. Let us review how to add the line ‘Twitterhandle’ into the registration form in Magento ®.

Why is the Twitter Handle necessary?

Many services that create and store visiting statistics data of web shops, blogs and diaries use information from Twitter in their work. These include link referrals, reviews, etc. If you wish to know your customers’ opinion about your store – this is the best way for you to uncover it.

Besides, this social network will help you significantly increase the number of potential customers and monitor the activity of customers you already have. It is quite simple to add the ‘Twitterhandle’ field to the registration form, all you need to do is correct the code. Also, check our free Social Connector.

Many web store owners tend to underestimate the power of Twitter. This is what this microblog network can give you:

1. Information about your customers, their problems, needs, and requirements;

2. Public opinion about the products of your company and about other companies (your possible competitors);

3. Possibility to help your customers make the right choice or give them an idea of buying this or that product;

4. Free promotion of your web store products;

5. Free advertisement of your products directly to the target audience.

How to add Twitterhandle

As we mentioned in other articles, Magento ® uses the following architecture of data: Entity – Attribute - Value. Based on that information, you only need to add another attribute in order to generate the line for Twitter. For that, you need to edit the file register.phtml. You will find it at the path app, then app\code\local\YourNamespace\Appname\sql\yournamespace_appname_setup\mysql4-install-1.0.php

Open the file in the editor and paste the following code at the beginning:

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'twitter', array(
'label' => 'Twitter handle',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'required' => false,
'position' => 1


In order to configure in which place the social network line will be located, find the following part in the file:

<label for="email_address"><?php echo $this->__('Email Address')
?><span class="required">*</span></label><br/>
<input type="text" name="email" id="email_address" value="<?php
echo $this->htmlEscape($this->getFormData()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="validateemail
required-entry input-text" />


You can find it using the combination of ctrl + F.

After the closing tag </li> paste the following code:

<label for="twitter"><?php echo $this->__('Twitter handle') ?></
<div class="input-box">
<input type="text" name="twitter" id="twitter" value="<?php
echo $this->htmlEscape($this->getFormData()->getTwitter()) ?>"
title="<?php echo $this->__('Twitter') ?>" class="input-text" />
<label for="twitter" style="color: #ccc;font-size:
85%;">Example: @packtpub</label>


Note that this line will be highlighted in bold text to attract attention, you can remove this point if necessary.

Remember that sometimes your customers will need to update the information on their social network page. In order to let them do it directly from your store, you need to modify the file edit.phtml.

Open the file in catalog customer/form/ and look for the following code:

<label for="email" class="required"><em>*</em><?php echo $this-
>__('Email Address') ?></label>
<div class="input-box">
<input type="text" name="email" id="email" value="<?php
echo $this->htmlEscape($this->getCustomer()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="input-text
required-entry validate-email" />


Below that code add the following:

<label for="twitter"><?php echo $this->__('Twitter handle') ?></
<div class="input-box">
<input type="text" name="twitter" id="twitter" value="<?php
echo $this->htmlEscape($this->getCustomer()->getTwitter()) ?>"
title="<?php echo $this->__('Twitter') ?>" class="input-text" />
<label for="twitter" style="color: #ccc;font-size:
85%;">Example: @ferdous</label>


After that, you need to change the template configuration file. For that, go to app/code/core/Mage/Customer/etc/, then open the file config.xml.

Basic changes will be done in Global, you need to replace that block with the following:



Now you are almost finished. You only need to add an object attribute. Go to app/code/core/Mage/Customer/Model/Entity/ and open file setup.php. Locate the fields responsible for customers’ email address, but remember that after any update of Magento ® all modifications in the core files will be erased. In that case, do not forget to add them again:

'email' =>array(
'type' => 'static',
'label' => 'Email',
'class' => 'validate-email',
'sort_order' => 60,


Add the following code:

'twitter' => array(
'label' => 'Twitter',
'required' => false,
'sort_order' => 65,


It is done. Save the changes and check how it works. The code was taken from

If you would like GoMage specialists to help you install Twitterhandle in Magento ® please email us directly or leave a comment on this article.

Contact us
Fill in the data using social media accounts
Thank you!
We will contact you shortly
Subscribe to Newsletter Learn the main secrets of creating a successful eCommerce project