Home » Uncategorized

Use of Twitter Data to Obtain Customer Loyalty

Twitter Data Collection

Twitter is a well-known social media platform in which users are allowed to create a unique account and post tweet on the topics of his/her taste. The popularity of this platform is growing and many users post tweets regarding their experience of the products or services they used. People are posting opinions and experience about the brand they have used, whether they are satisfied with the product or service and also their opinions are shared with many other people. Hence it becomes immensely important for vendors to know whether the consumers liked their products and consumers opinion about their products.

Traditionally, data collection about the satisfaction or feedback on the product or services is made through a survey. The traditional way of survey requires to dedicate manpower to spend time and effort to collect the data. Moreover, to carry out data collection through this form of survey consumes an enormous amount of time.

Twitter social media forum can be a better way to carry out a survey on people opinions. The opinions posted by people in terms of tweets can be gathered using specific hashtags. These tweets can be analyzed to make understand consumer’s opinion on the products or services. The following figures 1 shows twitter data collection using REST API using specific hastags.


Figure 1. Twitter data collection using REST API.

Sentiment Analysis of Tweets

Once the data collected from the twitter then various preprocessing steps are carried out on the data. Next, twitter data can be utilized for various purposes such as stock market prediction, sentiment analysis of movies, sentiment analysis on a new gadget, people opinion on current events etc. In figure 2, the sentiment analysis of tweets is shown. After the preprocessing step, the sentiment of tweets is analyzed and found the sentiment score. The tweet sentiment analysis can be carried out to help vendors to know consumer’s opinions.


Figure 2. Sentiment analysis of tweets.

VADER is a sentiment analyzer which stands for Valence Aware Dictionary and sEntiment Reasoner. VADER uses a lexicon and uses a set of rules to provide sentiment scores. Textblob is another sentiment analyzer which provides an output as a tuple (polarity, subjectivity).

Sentiment Analysis for Loyalty

Consumer loyalty can be measured using Twitter and analysis of twitter related data. The sentiment analysis on tweets gives an opinion of users in terms of sentiment scores.  The twitter also provides various other information such as a number of likes, retweeted a tweet etc. Here an idea proposed to compute the consumer loyalty using twitter related information. The tweets related to the airline industry are collected from twitter. The airline industries from various regions such as America, India, European and Australian are considered. The objective is to computer consumer loyalty to a specific airline based their tweet history. These tweets are collected using the search terms such as

460462090Each collected tweet consists of an ID, permalink, date and time stamp, the text contained within the tweet, username, retweets, and likes. Few tweets with likes and retweets are shown in below table.


Loyalty Measurement

Using Textblob the sentiment score for each tweet is computed as . The tweets having sentiment score greater than zero are considered as positive and less than zero are taken as negative tweets. Consider John is a frequent traveler and he uses several air lines. We can compute the mean of positive tweets and negative tweets by John for a particular airline as  



Results and Statistics


The left part of figure 3(a) represents the loyalty measurements for tweets obtained using the search terms “left airline”. These are customers who left the airline services and shifted to different service. The figure 3(b) show the loyalty measurement for the tweets obtained with the search term “loyal to airline” or “loyal flyer”. The average loyalty measurement in figure 3(a) is 19.6 while the average loyalty measurement for figure 3(b) is 252.7.

Research Paper

The research on consumer loyalty evaluation using twitter data is appeared in:


Cite the Work

Please cite the following research paper:

Rida Khan, Siddhaling Urologin, “Airline Sentiment Visualization, Consumer Loyalty Measurement and Prediction Using Twitter Data”, in International Journal of Advanced Computer Science and Applications (IJACSA), volume 9, issue 6, pp. 380-388, 2018.

Further Projects and Contact

For further reading and other projects please visit


Dr. Siddhaling Urolagin,

Department of Computer Science

BITS Pilani, Dubai Campus, Academic City

Dubai, United Arab Emirates

[email protected]

Leave a Reply

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