<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ReadyState4 &#187; Omniture</title>
	<atom:link href="http://readystate4.com/category/omniture/feed/" rel="self" type="application/rss+xml" />
	<link>http://readystate4.com</link>
	<description>JavaScript, Web Development, Ruby, and Technology.</description>
	<lastBuildDate>Fri, 04 Jun 2010 19:42:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Issue with Omniture&#8217;s Site Catalyst Form Analysis Plug-in</title>
		<link>http://readystate4.com/2008/03/11/issue-with-omnitures-site-catalyst-form-analysis-plug-in/</link>
		<comments>http://readystate4.com/2008/03/11/issue-with-omnitures-site-catalyst-form-analysis-plug-in/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 16:41:08 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Omniture]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/03/11/issue-with-omnitures-site-catalyst-form-analysis-plug-in/</guid>
		<description><![CDATA[Update: To further illustrate my discussion below I have created an example page with nothing but a basic form and Omniture code with the Form Analysis plugin. Clicking the submit button with Omniture enabled should alert the Form Object but notice in Firefox, Safari, and Opera the Window Object is instead alerted. Internet Explorer alerts [...]]]></description>
			<content:encoded><![CDATA[<p class="update" style="padding: 5px; background-color: lightyellow"><b>Update:</b> To further illustrate my discussion below I have created an <a href="http://readystate4.com/omnituretest/index.html">example page</a> with nothing but a basic form and Omniture code with the Form Analysis plugin. Clicking the submit button with Omniture enabled should alert the Form Object but notice in Firefox, Safari, and Opera the Window Object is instead alerted. Internet Explorer alerts the Form Object in both cases as it should.<br />
<b>How to fix the issue:</b> Omniture has to fix this issue. Somewhere in their code they need to change a direct function call to use that function&#8217;s <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Function:apply">apply</a> method instead so that they can keep the <code>this</code> reference targeting the same object.</p>
<p>I wanted to write about an issue I&#8217;ve been debugging with a particular sport&#8217;s team site and the issue ended up stemming from a conflict in Omniture&#8217;s Site Catalyst Form Analysis Plug-in with existing form validation code on the site. The form in question had a hard-coded event listener that (simplified) looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;addForm&quot;</span> <span style="color: #000066;">onsubmit</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;return validateForm(this)&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
     // form contents here
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>The function <code>validateForm</code> is being passed one argument, <code>this</code>, which is a reference to the form it&#8217;s attached to. This function validates the form and returns true or false (with false halting form submission.) When the Omniture code runs, it removes any listeners on the form and ques them up to run after Omniture&#8217;s listener. Since the Omniture code is running in the global namespace (window object) the <code>this</code> keyword of our form validation function is now referencing the global window object instead of the form it was originally attached to. Unfortunately, because of it&#8217;s obscured nature &#8211; I couldn&#8217;t find the specific mechanism directly causing the issue in their code during my Firebug debug session. I have tracked it down to the Form Analysis 2.0 plugin, which tracks form success/abandonment rates. I can see that when the Omniture code is in the page all references to <code>this</code> change to the window object, which is pretty horrific since <code>this</code> is the basis of writing object-oriented code.</p>
<p>Since I can&#8217;t see Omniture&#8217;s code to fix it, the only end solutions are:</p>
<ul>
<li>Removing all references to the <code>this</code> keyword in the site-specific code</li>
<li>Remove the Omniture plugin.</li>
</ul>
<p>I&#8217;m pushing for the latter as developers shouldn&#8217;t have to code around an analytics tool, and the Omniture guys really need to fix this. I&#8217;ve looked around and found a related Omiture conflict with <code>this</code> in the jQuery JavaScript framework:</p>
<p>&#8220;Conflict with Omniture javascript&#8221;<br />
<a href="http://dev.jquery.com/ticket/1295">http://dev.jquery.com/ticket/1295</a></p>
<p>As well as Dean Edward&#8217;s addEvent2 script:</p>
<p>&#8220;Anyone know why this code would conflict with Omniture’s SiteCatalyst javascript files?&#8221;<br />
<a href="http://dean.edwards.name/weblog/2005/10/add-event2/#comment196705">http://dean.edwards.name/weblog/2005/10/add-event2/#comment196705</a></p>
<p>For the above two scenarios, you may be able to move the omniture include above the other js includes so that it loads first, in my situation, I don&#8217;t have access to certain parts of the site so my options are limited. Hopefully this page will serve as a resource to others though, who also run across it.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/03/11/issue-with-omnitures-site-catalyst-form-analysis-plug-in/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
