Optimizing The SiteCatalyst Page Code

You’ve signed the agreement, you received your username, and you are ready to get started with Omniture SiteCatalyst. Or maybe you have had it a while, and are looking to optimize your installation. You’ve come to the right place. Let’s take a look at one of the two core pieces that make it work, the page code. The other piece, being the s_code.js file is a complicated animal, but the page code is pretty straight forward.

After logging in with admin privileges in SiteCatalyst, you can find the code files in the code manager in the admin console.

Here is the basic, vanilla, out of the box page code file.

<!-- SiteCatalyst code version: H.19.4.
Copyright 1997-2009 Omniture, Inc. More info available at
http://www.omniture.com -->
<script language="JavaScript" type="text/javascript" src="http://INSERT-DOMAIN-AND-PATH-TO-CODE-HERE/s_code.js"></script>
<script language="JavaScript" type="text/javascript"><!--
/* You may give each page an identifying name, server, and channel on
the next lines. */
s.pageName=""
s.server=""
s.channel=""
s.pageType=""
s.prop1=""
s.prop2=""
s.prop3=""
s.prop4=""
s.prop5=""
/* Conversion Variables */
s.campaign=""
s.state=""
s.zip=""
s.events=""
s.products=""
s.purchaseID=""
s.eVar1=""
s.eVar2=""
s.eVar3=""
s.eVar4=""
s.eVar5=""
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<script language="JavaScript" type="text/javascript"><!--
if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img
src="http://mysite.112.2O7.net/b/ss/mysite/1/H.19.4--NS/0"
height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst code version: H.19.4. -->

There is tons of stuff here that is completely unneeded. Lets try to strip it down a bit and see if we can lighten our page weight. Why? The lighter our page weight the quicker it will load. The lighter the page weight the more of the actual content will get indexed. Believe me, lighter is better.

The first thing we see is a basic introduction:

<!-- SiteCatalyst code version: H.19.4.
Copyright 1997-2009 Omniture, Inc. More info available at
http://www.omniture.com -->

This is absolutely not needed at all. Not a bit of it. But I do like to keep a small bit around just to keep developers who don’t know what it is aware of whats going on. For this first section I recommend chopping it down to:

<!-- SiteCatalyst Code  -->

Sweet and simple. No need to keep the version number in there either. Keep that in your s_code file where its needed.

Next thing we see is the call to the s_code.js file.

<script language="JavaScript" type="text/javascript" src="http://INSERT-DOMAIN-AND-PATH-TO-CODE-HERE/s_code.js"></script>

Yank this out too. But wait you say, I need that file, I can’t get rid of it! I’m not saying get rid of it, I just want you to move it. Keep all your JavaScript calls together where they belong, in the head section of your page. Move this call to the top of the page.
EDIT: There are some potential repercussions to moving this out of the BODY section. I like to keep the code nice and neat so I keep all the .js calls in one place but this is by no means without consequence. There is nothing wrong with keeping this line with all of the rest of the code.

Next up is the variable section.

<script language="JavaScript" type="text/javascript"><!--
/* You may give each page an identifying name, server, and channel on
the next lines. */
s.pageName=""
s.server=""
s.channel=""
s.pageType=""
s.prop1=""
s.prop2=""
s.prop3=""
s.prop4=""
s.prop5=""
/* Conversion Variables */
s.campaign=""
s.state=""
s.zip=""
s.events=""
s.products=""
s.purchaseID=""
s.eVar1=""
s.eVar2=""
s.eVar3=""
s.eVar4=""
s.eVar5=""

Tons of useless junk here. If your not using it dump it. Only fill out variables that are specific to whats going on with that page. Try to move as many things to the s_code.js file as you can. For example if you want to use the page titles as each page name in Omniture (which I think is a good practice) then just set that one time in the s_code.js file. Something like s.pageName=document.title; and no need for that code on the page. Try to move as much stuff as you can to that file.

On to the end

/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<script language="JavaScript" type="text/javascript"><!--
if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img
src="http://mysite.112.2O7.net/b/ss/mysite/1/H.19.4--NS/0"
height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst code version: H.19.4. -->

This section is a disaster. You have a huge noscript section that is udderly useless. The very very very first thing I do is to kill that section. I mean Omniture themselves don’t even use it. Kill it and never look back. That leaves you with this:

/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<!-- End SiteCatalyst code version: H.19.4. -->

The big scary “do not alter” message is somewhat important. Well the message itself, not that actual line of text. If I am going to have someone else install the code on their site I have them leave it, so hopefully they won’t touch anything they are not supposed to. If I am putting the code on the page myself then I yank that out too. The line that follows that is the money shot. That’s what makes it work. Don’t touch it. I usually never go near that line. I say usually because there is one time where I will touch it. More on that in a few. The final closing line, yank out the version and that one is good.

Lets take a look at the chopped down page code where we just set a single eVar and event.

<!-- SiteCatalyst Code -->
<script language="JavaScript" type="text/javascript"><!--
s.events=1
s.eVar1=blue
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<!-- End SiteCatalyst Code -->

Much better. Now I mentioned earlier that I would touch that one ‘money line’ of the code. If I have a site that I really don’t need much info on, and i can get everything I need from the s_code.js file I will hack everything down to the absolute bare minimum. You still need the call to the s_code.js file in the head section, that will never change, but the page code can be reduced to:

<script language="JavaScript" type="text/javascript">var s_code=s.t();if(s_code)document.write(s_code)</script>

A call to the s_code.js file and that single line is the bare minimum that is needed to make SiteCatalyst work.

Look at your page code. Move the call to the s_code.js file to the header, move everything you can to that file, and strip out all the unnecessary junk.

Leave a Reply