The s_code.js file – Core Javascript Code

This article is part of the mini series about the s_code.js file. You can find the other articles here:

Core Javascript Code

The biggest portion of the s_code.js file is the core Javascript code underneath the “DO NOT CHANGE” line.

In this part of the file, all the important client-side functionality of Adobe Analytics is defined. The “s object” creation method s_gi is declared along with a couple of helper methods.

Most importantly, s.t and s.tl are defined here, the two methods that you use to actually send tracking information. We have introduced s.t and will discuss s.tl at some point.

A big part of the code handles setting of the so-called “automatic variables”.

If you check with a debugger, you will notice that tracking calls actually contain a lot more than the data you set:

Data points like screen size (URL parameter “s”), browser width and height (“bh” & “bw”), colour depth (“c”), Javascript version (“j”), local time (“t”), the URL of the page (“g”) and others are automatically appended.

Depending on what browser you are using, you might see more parameters.

Netscape-based browsers send a list of installed plugins in the “p” parameter, while IE sends things like connection speed (“ct”) and whether the current page is the home page (“hp”). How useful those measurements are is a matter of discussion…

Closing Thoughts

The s_code.js file is the heart of all Javascript-based, client-side tracking in Adobe Analytics.

It does the heavy-lifting you’d expect from a library. It handles automatic variables. It provides the “s object” container that allows you to store data for transfer. It also provides you with methods to send that data.

On top of that, it contains the very useful s.doPlugins call back method, which allows you to handle everything that has to be done across the whole site in a central place.

The s_code.js file truly is the most important piece in the whole tracking picture.

Now having said that, we hope that in the future it won’t be.

Two reasons:

  1. The file really has two broader purposes, and those should be separated.
  2. Tag Management is on the rise, fortunately.

We can broadly group the four parts of the s_code.js file into two: core Javascript code versus the rest.

The core Javascript code gets an update every now and again. Adobe Engineering is driving these updates. While a year ago or so they shipped version “H.24.2”, we are now on version “H.25.4”.

Note: there is a change log available for the core Javascript code.

The rest of the s_code.js file will be updated by you or other implementers.

That raises an obvious question: how to easily integrate?

We will post an article on best practise, but for now let’s just say it would be easier if those two groups would be separate.

Secondly, tag management systems are more and more powerful and more customers are using them for convenience and sometimes enhanced functionality.

It makes a lot of sense to put at least some of the four sections that currently sit inside s_code.js into a tag management system instead.

So there you have it, our mini-series on s_code.js concludes. Please feel free to post any questions or remarks in the comments below this or the relevant posting! We’d love to hear from you!

About

German expat living in Switzerland (formerly UK and France). Consultant and member of the Multi-Solutions Group at Adobe, working with the Digital Marketing Suite. Father of 4 girls.

Tagged with: ,
Posted in Javascript, Principles
21 comments on “The s_code.js file – Core Javascript Code
  1. […] core Javascript code that defines how Adobe Analytics works in the […]

    Like

  2. […] you send off the tracking data (remember: call s.t()), the Javascript library takes all the data and builds an HTTP GET request that it’ll ask the browser to […]

    Like

  3. […] since version H.22.1, the Javascript library will take care of that by truncating the URL on IE if necessary, but if you still use older code or […]

    Like

  4. […] cX & vY parameters representing propX & eVarY, events, products and some of the built-in, automatic variables we mentioned before. All of those transport data and are not vital for tracking to function. Of […]

    Like

  5. […] even in this simple case there is one reason to use it: updating the “core” Javascript code is a matter of clicking in the UI rather than deploying a new […]

    Like

  6. […] core Javascript code that defines how Adobe Analytics works in the […]

    Like

  7. […] core Javascript code would build the complete URL for the tracking requests, which would look something like: […]

    Like

  8. […] the Javascript code was augmented with the s.abort flag — a flag that when set instructs the core Javascript code to not fire the tracking […]

    Like

  9. […] you have to use s_code version H.25.4 or later for this! If you implemented before February 2013, you might be on an older […]

    Like

  10. […] When you want to upgrade the core Javascript code […]

    Like

  11. […] not reliable. If you update your s_code.js file the way most people do (i.e. replace only the core Javascript code), the comment at the top will soon be hopelessly […]

    Like

  12. […] stage ends when you call the s.t() or s.tl() method and the core Javascript code takes […]

    Like

  13. […] your site uses version H.25.3 or later of the core Javascript code, you will also notice a cookie called “s_fid”, which is set via Javascript and […]

    Like

  14. […] like the core Javascript code in the s_code.js file provides everything needed for Adobe Analytics, the visitorAPI.js file […]

    Like

  15. […] data about the hit itself (such as the time it was received, the rsid or the version of your s_code.js/appmeasurement.js/Mobile […]

    Like

  16. […] You might remember that the file has 4 sections in it: configuration, doPlugins, plugins, and core Javascript code. […]

    Like

  17. […] core Javascript code makes that decision, and we therefore have to let it know those URLs as well. That’s where […]

    Like

  18. […] mini series pretty much covered it all, overview, configuration, doPlugins method, plugins, and the core Javascript code. So, what’s left to […]

    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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 1,398 other followers

%d bloggers like this: