Alan Whitehouse's Ramblings

Continuing to work until my heavy investment in lottery tickets finally pays off….

  • Categories

  • Archives

  • Deep Thought

    Historically speaking, all true change in the world has come thanks to leaders emerging, them taking charge and giving the masses someone to rally around. Can an intentionally "leaderless" movement survive or will it just slowly fade away?

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 19 other followers

  • Me!

  • Disclaimer

    The views expressed in this blog, while intelligent and always right, are strictly my own, and do not necessarily reflect the views of anyone else with which I am in any way affiliated. And don't forget, I own the rights to all information on this blog (except for the stuff I stole from other people).
  • Current Rant

    *START OF RANT*

    You want change, then get involved. Vote, run for office, go to shareholder meetings and contact advertisers or investors. Sitting around banging drums, singing kumbaya, smoking weed and having a camp out under the stars is not going to get you the change you want.

    *END OF RANT*
  • Admin Stuff

Integrating PerformancePoint with Twitter

Posted by Alan on April 19, 2011

Next month I (on behalf of TGO Consulting) am doing a BI presentation at the Spring 2011 IT Forum for the Certified General Accountants of Ontario and I have been racking my brain to come up with some new twists to the presentation as I just didn’t want to show the same old stuff.  After much thinking I decided I was going to show how PerformancePoint Services can be integrated with Twitter.  Now why would you want to do this you ask? Why wouldn’t you want to do this I say!

In a perfect world, all data would be in a structured format (i.e., stored in databases and normalized) that would lend itself to quick, easy and powerful slicing and dicing to support the decision-making process.  Unfortunately we don’t live in that perfect world and huge amount of the data that decision makers need lies in an unstructured format.  This data resides in things like Word documents, Emails, Excel spreadsheets, PDFs and on the internet in forums and websites.  The dilemma is that compiling and analyzing this unstructured data is time consuming and difficult, but not doing so means that decisions are being made based on incomplete data sets.

Social media is all the rage right now and will continue to be so until the next big thing comes along.  An amazing amount of data on how individuals view your brand/product/service lies within sites like Facebook or Twitter.  Piss a customer off in the past and they tended to tell 10 friends about their bad experience.  Piss them off today and 2 minutes later they have posted on their wall or tweeted to 1000 people about their bad experience.  Ignore social media at your own peril.

This is where using SharePoint as a BI platform really shines. SharePoint in general and PerformancePoint Services in particular provide a platform that can easily tie together the structured data found in the line of business systems within most organizations with the ton of internally stored unstructured data that we all interact with on a daily basis.  With a few simple extra steps we can extend that integration to the unstructured social media data out on the interweb.

As a preface I want to point out that I am not a developer by trade — I am a hack.  Whatever code you see here should be taken with a grain of salt as someone who actually knows what they are doing with code can probably do it more efficiently and cleaner.  When I decided to start this project I knew I was going to use the Scorecard and thought I might use the out of the box RSS web part within SharePoint.  But search and research as I might, I found no way to pass parameters from the Scorecard to the RSS web part.  After some more searching I came across an old yet excellent blog post by Nick Barclay that got me started on a workable framework for my solution as did a post in the Microsoft PerformancePoint forum on TechNet.  Some more searching turned up the fact that Twitter has numerous exposed APIs for getting at information in different formats.  I played around with most of them before I decided I would use the Search Widget.  I did this because I liked the look and feel and because Twitter is kind enough to generate the code I needed for it.  The Search Widget is in Java so rather than pull my hair out trying to marry JavaScript and ASPX/C# (remember I am not a developer) I decided to write my page in straight HTML.  So to that end, I needed a way to pass a parameter in HTML like Nick had shown in ASPX and I found it in a post by someone who goes by the name Uzbekjon at a site called JQuery HowTo.

The final solution lets a user click on a dimension member name in a PerformancePoint dashboard and then have the results of a Twitter search appear next to it.  Jump to the bottom to see the final results or continue scrolling down to see a step-by-step description of how it all comes together:

Step 1: Create a Web Site on Your SharePoint Server to Host Your Twitter Search Results Page. Mine is http://localhost:9090/.

Step 2: Using the tool of your choice create a basic HTML page and call it “TwitterSearchResults.html”.  I am using Notepad ++ (shout out to Dan English for telling me about this tool) and it starts simple enough.

  1: <html>
  2: <!-- This PerformancePoint to Twitter Search Results Page was created by Alan Whitehouse -->
  3: <!-- http://alanwhitehouse.wordpress.com and http://www.twitter.com/alanwhitehouse --> 
  4:
  5: <head>
  6:
  7: </head>
  8:
  9: <body>
 10:
 11: <body>
 12:
 13: </html>


Step 3
:  Add the code to extract the parameters that are within the URL that our page will be receiving from the PerformancePoint scorecard.  To note is line #20.  The syntax here caused me some headache before I figured out what I should put.  I kept using “EndPoint_URL” which is what you see in the technical documentation but in reality what was coming across was “EndPoint%5FURL” where “%5F” is the translation for the underscore character.

  1: <html>
  2: <!-- This PerformancePoint to Twitter Search Results Page was created by Alan Whitehouse -->
  3: <!-- http://alanwhitehouse.wordpress.com and http://www.twitter.com/alanwhitehouse --> 
  4:
  5: <head>
  6: <script language="JavaScript" type="text/javascript">
  7: function getUrlVars()
  8: {
  9: var vars = [], hash;
 10: var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 11: for(var i = 0; i < hashes.length; i++)
 12: {
 13: hash = hashes[i].split('=');
 14: vars.push(hash[0]);
 15: vars[hash[0]] = hash[1];
 16: }
 17: return vars;
 18: }
 19:
 20: var SearchTerm = getUrlVars()["EndPoint%5FURL"];
 21: </script>
 22: </head>
 23:
 24: <body>
 25:
 26: <body>
 27:
 28: </html>


Step 4
:  Add the Search Widget code from Twitter to your HTML page.  The easiest way to get this code is to visit the Twitter site I mention above and use the tool they have there to generate the code for you.  By design, the tool looks to hard-code the search parameters and if you look at line #30 below, you will see that I have replaced the default value with my variable that I created in line #20.  Save your finished HTML page to the web site you created in Step 1 above.

  1: <html>
  2: <!-- This PerformancePoint to Twitter Search Results Page was created by Alan Whitehouse -->
  3: <!-- http://alanwhitehouse.wordpress.com and http://www.twitter.com/alanwhitehouse --> 
  4:
  5: <head>
  6: <script language="JavaScript" type="text/javascript">
  7: function getUrlVars()
  8: {
  9: var vars = [], hash;
 10: var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 11: for(var i = 0; i < hashes.length; i++)
 12: {
 13: hash = hashes[i].split('=');
 14: vars.push(hash[0]);
 15: vars[hash[0]] = hash[1];
 16: }
 17: return vars;
 18: }
 19:
 20: var SearchTerm = getUrlVars()["EndPoint%5FURL"];
 21: </script>
 22: </head>
 23:
 24: <body>
25:  <script src="http://widgets.twimg.com/j/2/widget.js"></script>
 26: <script>
 27: new TWTR.Widget({
 28:   version: 2,
 29:   type: 'search',
 30:   search: SearchTerm,
 31:   interval: 1000,
 32:   title: '',
 33:   subject: '',
 34:   width: 'auto',
 35:   height: 300,
 36:   theme: {
 37:     shell: {
 38:       background: '#ffffff',
 39:       color: '#ffffff'
 40:     },
 41:     tweets: {
 42:       background: '#ffffff',
 43:       color: '#444444',
 44:       links: '#1985b5'
 45:     }
 46:   },
 47:   features: {
 48:     scrollbar: true,
 49:     loop: false,
 50:     live: true,
 51:     hashtags: true,
 52:     timestamp: true,
 53:     avatars: true,
 54:     toptweets: true,
 55:     behavior: 'all'
 56:   }
 57: }).render().start();
 58: </script>
 59: <body>
 60:
 61: </html>


Step 5
:  Go into Dashboard Designer and create a new Web Page Report.  Point the URL to your website location where you have stored the “TwitterSearchResults.html” web page we designed above.

Step 6: Create the KPI you want to use on the Scorecard.

Step 7: Create the Scorecard you want to use in the Dashboard.

 

Step 8: Pull your Scorecard and Web Page Report into a Dashboard and connect the Scorecard to our Twitter Search Web Page Report.

  

 

Step 9: Deploy your Dashboard and view the results.  You will notice that whatever row name you click on becomes a search term for Twitter.  In addition, if you click (no image shown) on one of the Tweets the Twitter JavaScript code will actually allow you to interact with the Tweet and reply or retweet it or to add the person to your follow list.

Obviously there are additional formatting and cosmetic changes that can also be done but what I like about this solution is that you can attach the Twitter Search Results report to pretty much any Scorecard and it will work without having to change a line of your HTML code.  If you can streamline my code or process I would love some suggestions.  Also, if anyone has a good suggestion for posting code examples into WordPress that format nicely and is quick to use please let me know.

Advertisements

4 Responses to “Integrating PerformancePoint with Twitter”

  1. denglishbi said

    That is simply awesome Alan, fabulous post and great idea. Nicely done and keep it up:)

    I was using a code snippet add-in with LiveWriter, but it is/was awful. I finally took the time to look into this a bit more now and WordPress.com does support a sourcecode highlighter from http://alexgorbatchev.com/SyntaxHighlighter/ and the instructions on how to reference it are here – http://en.support.wordpress.com/code/posting-source-code/ and you can simply tell it which language you want it to leverage for highlighting. I first saw this setup on one of Jason Strate’s postings (http://jasonstrate.com) It also provides provides options for the user to easily copy, view, and print the code as well. Just need to figure out how to get this to play nicely in LiveWriter now with line feeds and carriage returns. I just used this setup and update a posting I have here to take a look at – http://denglishbi.wordpress.com/2011/04/13/using-sharepoint-list-data-for-reporting-services-ssrs-parameter-source/.

  2. Alan said

    Thanks for the feedback and thanks for the code snippet suggestion. I tried downloading like 5 different ones for LiveWriter and all were average at best.

  3. I’m truly enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it
    much more pleasant for me to come here and visit more often.
    Did you hire out a designer to create your theme?
    Exceptional work!

  4. Grupo Mayan pros will tell you all of your energy is not lost or displaced while hill climbing.
    I lurched on, struggling to maintain the diet,
    the weight begins to come back later for a
    service or a spare part. Apart from them, the focus is on the path.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: