Use Omniture’s Data Insertion API to avoid insanely long URL query strings

If you have not already found the Web Analytics Land blog, you need to check it out! I was re-reading another post out there A Robust SiteCatalyst Implementation Could Fail In Internet Explorer, where he talks about the issue you could face with a SiteCatalyst Implementation in IE is the URL string to the Javascript Beacon exceed 2083 characters.

From Web Analytics Land: Why do we need to care about this? It lies in an inherent deficiency of Internet Explorer. IE can not accept a URL that is longer than 2083 characters. If your implementation is pretty complex and you are passing in a lot of variables, your image request can easily approach if not exceed that amount. Since Microsoft still commands the lion’s share of the browser marketplace, this is something we need to keep an eye on. If this was a problem with Opera or another third or forth tier browser then we may not worry about it. But this is not the case with Internet Explorer.

I have made no effort to conceal my hatred of IE 6. timesup

However,  like many others out there, it is the reality that we have to deal with.  So I looked at the example url that was provided over at Web Analytics Land and wondered if I could take that url string and convert it into an xml object that I would then be able to use Omniture’s Data Insertion API instead of the Javascript Beacon to send as long of a data push as needed.

My plan was to using ColdFusion, my preferred development language, take the nasty url and convert it into a Structure and then build an XML document to post to Omniture.

First I needed to just copy the url string into a ColdFusion variable to begin the process.

<cfset variables.testurl2 = "AQB=1&pccr=true&vidn=2555563F85011AB6-6000010100004DB6&&ndh=1&t=26/5/2009%2016%3A47%3A53%205%20240&ns=classifiedventures1&pageName=results&g=http%3A//">

What a mess! Next I needed a Struct to be able to reference later that held the accepted XML tags for the Data Insertion API and the codes from the url.

NOTE: This is not meant to be a complete list of all options!

<!--- build static stuct for use in building the xml --->
<cfset variables.OmnitureXMLConverter = structnew()>
<cfset = "browserHeight">
<cfset = "browserWidth">
<cfset variables.OmnitureXMLConverter.v0 = "campaign">
<cfset = "channel">
<cfset variables.OmnitureXMLConverter.c = "colorDepth">
<cfset variables.OmnitureXMLConverter.ct = "connectionType">
<cfset variables.OmnitureXMLConverter.k = "cookiesEnabled">
<cfset = "currencyCode">
<cfset = "events">
<cfloop from="1" to="50" index="x">
 <cfset variables.OmnitureXMLConverter["c#x#"] = "prop#x#">
<cfloop from="1" to="50" index="x">
 <cfset variables.OmnitureXMLConverter["v#x#"] = "eVar#x#">
<cfloop from="1" to="5" index="x">
 <cfset variables.OmnitureXMLConverter["h#x#"] = "hier#x#">
<cfset variables.OmnitureXMLConverter.hp = "homePage">
<cfset variables.OmnitureXMLConverter.v = "javaEnabled">
<cfset variables.OmnitureXMLConverter.j = "javaScriptVersion">
<cfset variables.OmnitureXMLConverter.pev2 = "linkName">
<cfset variables.OmnitureXMLConverter.Pe = "linkType">
<cfset variables.OmnitureXMLConverter.pev1 = "linkURL">
<cfset variables.OmnitureXMLConverter.pageName = "pageName">
<cfset variables.OmnitureXMLConverter.pageType = "pageType">
<cfset variables.OmnitureXMLConverter.g = "pageURL">
<cfset variables.OmnitureXMLConverter.p = "plugins">
<cfset variables.OmnitureXMLConverter.products = "products">

This provided a nice CFML struct omnixmlstruct

The next step would be to take the long url and break it up into a list or it’s own structure.   I bounced a few ideas off of a fellow CFML coder and ended up with the following code block:

<cfset variables.urlStructSample = structnew() >
<!--- Break up the url into sections --->
<cfloop list="#variables.testurl2#" index="listItem" delimiters="&">
 <!--- split into smaller sections --->
 <cfset variables.varName = listgetat("#listItem#",1,"=")>
 <cfset variables.varValue = urldecode(listgetat("#listItem#",2,"="))>
 <!--- build a new struct with values --->
 <cfif StructKeyExists(variables.OmnitureXMLConverter, "#variables.varName#")>
 <cfset variables.tempHolder = variables.OmnitureXMLConverter['#variables.varName#']>
 <cfset variables.urlStructSample["#variables.tempHolder#"] = "#urldecode(variables.varValue)#">
 <!--- <cfset variables.urlStructSample["#variables.varName#"] = "#urldecode(variables.varValue)#"> --->

This code will take the url, and break into a list using & as a delimiter.  Then it will compare the list to the struct holding the xml tags and if a match is found it will build a new struct that has the xml tag as the struct keys and the values needed to be passed as the values.  Resulting in a struct like this:


Next, we take this struct and build a properly formatted xml object to push to Omniture:

<cfset variables.OmnitureURLList = StructKeyList(variables.urlStructSample)>

<cfset variables.xmlString = "">
<cfloop list="#variables.OmnitureURLList#" index="newListItem">
 <cfset variables.tempValue = variables.urlStructSample["#newListItem#"] >
 <cfset variables.xmlString = variables.xmlString & "<"  &  "#newListItem#"  & ">"  &  "<![CDATA[#variables.tempValue#]]>" &   "</"  &  "#newListItem#"  & ">" >

<cfxml variable="xml2Omniture" >
 <?xml version="1.0" encoding="utf-8" ?>

This code will result in an xml object like this:


Last step would be to push the xml object to Omniture:

<cfhttpparam type="XML" value="#xml2Omniture#"	 />

I have not done any testing to see what impact this process would have on site performance or how it performs against the normal JS beacon.  But if you have a situation where the amount of data that had to be passed to Omniture exceed the magic 2083 characters, this is an approach you could take.

Thanks to Web Analytics Land for his original post, and thanks to Craig for bouncing some ideas back and forth on this.


Leave a comment

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

Are you human? Or are you Dancer? *

6 thoughts on “Use Omniture’s Data Insertion API to avoid insanely long URL query strings”