Back in April I wrote a blog post titled ‘Analytics All-Stars: Create Custom Dashboards Using APIs.’ The post described the high-level framework needed to create actionable dashboards outside of the SiteCatalyst interface. After publishing the post, I received comments from several people asking for more detailed instructions on how to create custom dashboards, so I decided to create a 3 part series detailing each step in the process.
Part 1: Getting the Data
Part 2: Storing the Data
Part 3: Building the Dashboard
Your assignment. Create a custom dashboard to display your site’s top 5 pages. The dashboard will be delivered to executives daily and will trend the page views for each page against the previous day as well as the previous same day of the week.
By the end of Part 3 of this series, you will have all the information you need to complete your assignment.
Part 1: Getting the Data
In Part 1, we will review how to extract data from your Omniture SiteCatalyst report suite using the SiteCatalyst Reporting API.
What you will need:
→Undertanding of Omniture’s REST API
→Access to a SiteCatalyst report suite with data
→A SiteCatalyst user with Web Service Access rights
→A server running PHP
→A working knowledge of PHP
The Rest API
Before we go any further, I strongly suggest that you take a few minutes to read Andreas Dierl’s post titled ‘How to start with the Omniture REST API in PHP.’ In this post, Andreas provides a great overview of how to use the REST API to retrieve data using the SiteCatalyst Reporting API. His post will serve as the foundation for this series.
Web Service Access
We will need a user that has Web Service Access for your SiteCatalyst login company. To give a user access rights, you will need to be a SiteCatalyst admin.
Navigate to Admin–>Admin Console–>User Management
Edit the user account for the user that you will grant Web Service Access to. In the ‘Access’ area of the User Management screen add ‘Web Service Access’ as shown below.
Make note of the ‘User Name’ and ‘Shared Secret’ we will need these values shortly.
We will need to gather a few other details in order to successfully connect to the appropriate SiteCatalyst Report Suite.
→API Server: If your repor suite is located in San Jose then your server will be ‘https://api.omniture.com‘ If your report suite is located in Dallas then your server will be ‘https://api2.omniture.com‘ If you don’t know where your report suite is located, contact ClientCare.
→Report Suite Id: Retrieve the Report Suite Id for the suite you wish to extract data from.
As mentioned in Andreas’ post, we will make use of an existing class, SimpleRestClient.class.php, to make coding our script a bit easier. Download the script before continuing and upload it to your server. NOTE: To keep everything organized, create a new directory to house all the files associated with this project.
Download Omniture REST API Template
Rather than building the script from scratch, I highly suggest modifying an existing template. Download the Omniture REST API Template that was developed by Andreas Dierl.
Rename the file to ‘dashboard.php’ and upload to the same directory you uploaded SimpleRestClient.php.
Configure the Script
Now that we have a template in place, let’s configure the script to retrieve data from your report suite. Open the script in your favorite text editor and make the following updates:
→Line 5: $username = ‘INSERT_USER_NAME_HERE’;
Update this line to contain the Web Services User Name that we created previously. It will look something like ‘login:company’
→Line 6: $secret = ‘INSERT_SECRET_HERE’;
Update this line to contain the Shared Secret that we created previously. It will look like a random string of numbers and letters.
→Line 11: $server = “INSERT_SERVER_HERE”;
Update this line to contain the server associated with your Report Suite. Either ‘https://api.omniture.com’ or ‘https://api2.omniture.com’
→Line 26: “reportSuiteID”:”INSERT_REPORT_SUITE_ID_HERE”,
Update this line to contain your report suite Id.
You can optionally update lines 27 and 28 to change the reporting time frame. For this exercise, we will run the script daily using the previous date as our timeframe.
To automate the script, we would need to programmatically assign the ‘dateFrom’ and ‘dateTo’ to ‘YESTERDAY’ rather than hard coding a date. You could use the following:
Save the updated script to your server.
Test the Script
That’s it! We are ready to test the script. This script will return the Top 5 Page Names by Page Views for the selected period. This is a simple example we are using to teach the process, you would update the Elements and Metrics used in the script to match the data needed to create your custom dashboard.
To test your script, point a web browser to the location of your script, something like ‘YourServer.com/omniture/dashboard.php’
If everything is working as we expected, you should see a list of your top 5 pages in the format of ‘Page Name – Page Views’
Example Report Output
Page – PageViews
Corp : Home Page – 41
Corp : The Management Team at Keystone – 22
Community : /community/ – 22
Corp : Services – 16
Corp : Contact – 12
In Part 2 we will talk about how to take the output from the script and insert it into a database.