The s_code.js File – Overview

This article and the following four will discuss a file that is vital for Adobe Analytics: the s_code.js file.

We’ll explain what it does and why you need it. We’ll tell you what you have to configure inside the file. We’ll also give you some tips around using it to make your life easier.

Overview

The s_code.js file contains 4 parts:

  1. a section with configuration variables,
  2. the definition of a useful callback method called s.doPlugins(),
  3. space for defining “plugins“, and
  4. the core Javascript code that defines how Adobe Analytics works in the browser.

[Screenshot]
The s_code.js File
The first section is about configuration. Line 10 is the most important part, it tells the system where the tracking should go, into which “report suite” (think of it like a database).

We’ll get to the concept of a repoert suite and to the other settings in a separate post.

The second section, from line 30 – 50 in the screenshot, contains the definition of the s.doPlugins() callback method.

We’ll get to it later as well, as it is a) really important and b) allows you to automate a lot of your tracking.

For now we’ll just mention two things:

The callback will be executed whenever a tracking call is sent to the Adobe servers, just before it is actually sent. So, when you call s.t() somewhere on a page, the system collects some data, then calls s.doPlugins() and then sends everything off.

Example: in the screenshot we assign s.campaign on lines 32 – 36. This allows us to pick up tracking codes for campaign tracking anywhere on the site without additional code on any page!

The third section, from line 51 – 132, contains the definition of the plugins we use in s.doPlugins(). Some of these you get from your Adobe consultant during implementation. Some of them you can download from the Adobe knowledgebase, and some even float around on the Internet. You can even write plugins yourself, of course!

Lines 134 – 138 contain more configuration. This bit you will probably never touch.

Everything down from line 140 to the end is the core Javascript library code. Again, you would probably never touch this.

How do I get the file?

You can get the s_code.js file in two different places: 1. from the Adobe consultant who helps you with the implementation, and 2. straight out of the SiteCatalyst Admin interface.

The former will likely have plugins added whereas the latter won’t.

It usually makes more sense to use the code that the consultant gives you. But there are exceptions, the most important one being when you want to update the core JS library to the latest version.

The official way of getting the latest code has two flavours:

  1. Use Adobe Tag Manager which can automatically update it for you, or
  2. Download the latest version from the SiteCatalyst Admin UI, then transfer your plugins and other customisations over into the new file.

The unofficial, simpler way is to just take all the code below line 140 (or whereever the core JS starts in your file) from the new file into your existing s_code.js file. Works a treat.

Make sure you test before you put the new s_code.js file live!

So much for now, look for the other four articles over the next couple of days!

37 thoughts on “The s_code.js File – Overview

  1. Hi Thanks for the post. When using Tag Manager 2.0, is it necessary to paste in the plugins? And where do they go? I can’t seem to get my plugins to ‘fire’ on ATM 2.0.

    Thanks – any further posts/discussions on ATM are welcome and appreciated!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.