QV Source and Google Analytics – Retrieving Data

 
I have been fortunate enough to work with a new product from Industrial Code Box.  QVSource is a great tool that allows you to connect QlikView with all sorts of web-based data services.  There are some very interesting connectors including Facebook, Twitter, Klout, LinkedIn, OData,  Infochimps and YouTube available with this tool.
But the connector that I have most used so far is the QVSource connector for Google Analytics.  Google rules the web statistics space as it does anywhere else they enter.  And included with Google Analytics is the ability to feed data directly through an API.  QVSource makes use of this feed and converts it into QlikView script that any developer can use to harness your Web Analytics with the power of QlikView.
The first step for creating an application is to open up QVSource and configure the connector.
 You will enter the GA user and credential.  Then click the URL build link.
This will open up the GA Data Query Feed Explorer.  You must be logged in to a gmail account that has read access to the GA account.  If you click in the “click to list your accounts” box and nothing happens, make sure:
  • Your gmail account has the correct access.
  • Try Logout and Reauthorize.
  • Or use Google Chrome as your browser.  The accounts box does not authorize correctly when using IE, even if you are signed into gmail.

Then you can use different combinations of dimensions and expressions to design the queries you need.  Keep in mind that GA only allows a maximum of 7 dimensions and 10 expressions.  Also, GA does not provide a unique user ID (against their policy).  So it can be a bit of a challenge to get down to the lowest detail possible.  As we know, QlikView breathes deeply in that granular level.  I have found that creating multiple queries can be effective if most of the dimensions are repeated to form a key and then you can cycle through any other needed dimensions.  In my case, I used latitude, longitude, date and hour as a key for all my queries.  That allowed me to bring in other dimensions 3 at a time.  Disregard the note that says max 10,000 records.  The query window is limited by 10,000, but the API call is not.
Once you find a query you want to use, simply copy the URL that forms above the query box and paste it into the URL box in QVSource.  Then select the Connector Data tab.  Select Data and then click the QlikView Load Script tab.  You will now see the load script you will need to use in your QlikView application.
Simply paste your script into QlikView and reload.  One thing to remember is that QVSource will need to be open any time you reload the application.  I found it helpful to open QVSource using Windows scheduler so that it works like a service.  Alternatively, you could use QlikView server to open the program before the reload runs.
You now have Google Analytics as a source for QlikView.  I am having lots of fun duplicating GA visualizations and surpassing them with my own creations.  And the client I have developed the QlikView document for is ecstatic with the results.  We are now talking about adding in Twitter and Facebook Page statistics to get a more integrated Web Strategy application.
0 comments

Hierarchy – Reflexive Transitive Closure

I have always wanted to make more use of the list box with the tree view option.  It has several advantages that make it a great way to select dimensions in QlikView:
  •  Ability to fit several selectable fields into a single object.
  •  Naturally shows the hierarchal relationship for the displayed fields.
  •  Intuitive to navigate for anybody who has come within 100 yards of a computer.
But many people, including myself have shied away from using the Tree View option because it is hard to get right.  What developers quickly realize is that selecting a non-leaf parent does not associate to the children of that parent.  This is because the QlikView function, Hierarchy, creates an expanded nodes table, but does not create the optimal Reflexive Transitive Closure style of this table.
Expanded Nodes table using Hierarchy function alone:
NodeID
Name1
Name2
Path
Depth
1
Agatha
Agatha
1
2
Agatha
Aaron
Agatha/Aaron
2
3
Agatha
Adam
Agatha/Adam
2
In above table if Agatha has no sales because she is the manager, when someone selects her in the Tree View list box the sales for children Aaron and Adam will not appear.  In addition, this behavior is even more confusing because the path changes depending on whether Agatha is expanded or not.  This results in the association sometimes working and sometimes not working.
Reflexive Transitive Closure:
NodeID
Name1
Name2
Path
Depth
2
Agatha
Aaron
Agatha
1
2
Agatha
Aaron
Agatha/Aaron
2
3
Agatha
Adam
Agatha
1
3
Agatha
Adam
Agatha/Adam
2
In this version, the association will work correctly every time.  This is because the NodeID (linking back to your transactions) has extra rows to account for the changing path as one clicks higher in the hierarchy.  Only the leaf nodes (NodeIDs existing in transactions) need to be included in the table.
Now the question is how would you create this table.  I have created a downloadable example with the actual script:  Hierarchy - Reflexive Transitive Closure.qvw
But here are the steps.
  • Load in transactions first because they will be used to identify the leaf nodes.
  • Use an exists(NodeID) or a join to add an IsLeaf flag to your adjacent nodes data.  You can load the adjacent nodes table using exists in one step.  I chose to use a join after the adjacent nodes load to keep the solution portable.
  • Use the Hierarchy function to flatten your adjacent nodes table into an expanded nodes table.  You will want to use the Path option and remember to leave in your IsLeaf field.  This leaves you with the traditional hierarchy table that includes all nodes.
  • We only need the leaf nodes so now we resident load this table into a new table, only loading the leaf nodes and sorting by the depth of the levels.
  • Now we create a looping structure going from the deepest level and working up to the highest parents.  Each loop adds records up the hierarchy so that a child has a corresponding path all the way up.  The loop will run for as many levels as you have minus 1.
  • Then just drop any of the temporary tables you created and any extraneous fields not needed in the final data structure.
So this will create an expanded nodes table with reflexive transitive closure.  There are still some issues with the way QlikView handles this:
  •          You will want to select Suppress Horizontal Scroll Bar in the list box due to a rendering issue in AJAX. 
  •           There will still be some confusion in selecting because depending on whether the parent is expanded or not, the children might not look selected.  I have not been able to work through that and have not had successful results trying to tie a trigger to it.
  •           The last item is that if you have a model where the parents have transactions as well as the children (different levels), you cannot isolate the parent’s transactions in the list box, since we have forced the association to the children.  The solution here would be to either go back to the traditional hierarchy table or to use an additional list box to select a single parent.  I mostly find this to not be an issue since usually the transactions are only at the lowest level.
Please enjoy and I look forward to any comments or additional analysis on this topic.
2 comments

Living QlikView

When people ask me what I do for a living, I often say I am Living QlikView.  And of course, this is primarily because I make my living developing QlikView applications for companies.  But it is also because I love what I do.  QlikView has given me the opportunity to finally give business users what they always wanted:  Effective information that allows them to make better decisions quickly.

Growing up in the world of distribution, I was constantly challenged to give people information they could use.  And it seemed like the old one-two combo of SQL and Crystal was just never good enough.
But what if I want to see this by customer?
or
I really want this by week, not month.
or the challenging
I want to be able to toggle back and forth easily through different filters.
or the hardest of all to explain
Why do I always have to call you to get this done?
 
Then in January 2010 I was introduced to a revolutionary solution called QlikView.  Now I could give users what they always wanted.  I can’t tell people how relieved I am to change my “We can’t do that” to “What else do you want?”  So in the last few years QlikView has completely changed the conversation for my clients.  We used to talk about if we can get a workable report.  Now we talk about “what if” scenarios and what used to be pie-in-the-sky ideas.  We now talk about how to get to better decisions, which is what this should have been all along.  The users have gone from tired-eyed frustration to wide-eyed enthusiasm.  And I have found my place, finally bridging the gap between the technology and the business user.
0 comments
Page 19 of 19
1 17 18 19

Join us at Living QlikView

Never miss a post.

We Never Spam. NEVER.

other sites

ASKQV One Spot – Many QV Blogs
Visual Data Group My QlikView partner
Official Qlik Community The great Qlik Community
QViewer Handy QVD Viewer

Show Buttons
Hide Buttons