Social media optimization is a critical part of a modern CMS. At Say Media we've built a service that collects sharing statistics from seven of the most popular social networks (including things like the number of Facebook shares and likes, Twitter retweets and favorites, Pinterest pins and repins and so on). Given the number of articles across all the sites that are powered by Tempest, this represents millions of data points per day.

While traditional statistical analysis of this data is important to understand how well our social media integration is doing, what is special about our Tempest system is the real time analysis. We're able to ingest this flow of data and maintain real time statistics about an article or a set of articles. The derived data is instantly available to be re-injected on the sites to help guide which content is highlighted.

As an example, take the xoJane.com homepage.** **Part of the homepage is made of articles automatically selected based on the traction they are getting on Facebook and Twitter. The idea is to detect articles that are popular on social media and help new visitors to the site discover those articles as well.

Each time a new data point is acquired for a given article, (such as a new number of shares on Facebook or Twitter), we compute a trending score for that story.

Here's an example of a trending score at work (it involves math and functions, so skip this section if it makes your brain hurt):

## Recommended Articles

**1. Pick an arbitrary maximum number of shares** for an article on given social network - let's say 1 million. An article can get more, but we are more interested in finding the trending ones than in keeping record highs.

**2. Bring this number down to a number between zero and 1,000.** The idea here is to find a bijective function that goes from zero to 1 million to zero to 1000. It can be a simple linear function, but in order to compress the high values and get more definition to the low value, we preferred using a log function.

**3. Compute the aging coefficient.** Given a time window that starts at the article publication and ends at an arbitrary age, say 3 days, we have to define a bijective function that goes from zero to 3 days to one to zero. This can be a simple linear function, or a more sophisticated one to favor or not recent articles.

**4. The multiplication of the normed number of shares with the aging coefficient** gives us a number that fluctuates between 0 and 1000, the trending score.

Tempest computes this in real time and maintains a list of the top 100 trending articles on each site per trending algorithm. We're currently experimenting with a dozen different trending algorithms, varying the time window, the aging and norming function, and the source of the signal. The results are used to power parts of the homepage or other sections of the site.

It's a work in progress but we're excited about the possibilities.

So the next time you want to see your favorite story at the top of xoJane or another Tempest site? Just share it on your favorite social network.