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!

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
34 comments on “The s_code.js File – Overview
  1. Billy Dixon says:

    Thanks Jan, A really useful overview… eagerly awaiting the next articles in the series.

    Regards,

    Billy Dixon
    @appliedwa

    Like

  2. […] proxies let you tweak the requests, the pages or even the s_code.js file on the fly. (Look for a feature called “Map Local” in Charles!) Extremely useful […]

    Like

  3. […] can add “plugins” to the s_code.js file. Those plugins can capture data independently of page code (i.e. on every page on the site). Good […]

    Like

  4. […] the s_code.js file. At the top, you will see a value being assigned to the s_account variable. Voilà, […]

    Like

  5. […] you tag a web page, you use Javascript and a file called s_code.js that contains the definition of all Analytics-related functionality used on the […]

    Like

  6. Mitchell Lee says:

    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

  7. […] might remeber that the s_code.js file contains 4 […]

    Like

  8. […] variables that would usually be set within the doPlugins method in the s_code.js […]

    Like

  9. […] described in the article on basic tracking, you have to do three things: a) load the s_code.js file, b) assign “variables”, c) send it all off using the s.t() […]

    Like

  10. […] that properly and your page code will essentially be three lines: one that loads the s_code.js file, one that assigns your data to s.contextData and one that calls […]

    Like

  11. […] way, grab the fb_ref parameter using the getQueryParam plugin within the s.doPlugins method in the s_code.js […]

    Like

  12. […] top use case: modify the s_code.js file and see the results in the live […]

    Like

  13. […] the way to achieve that is to rename one of the two objects. This would normally been done in the s_code.js file, most likely by an Adobe […]

    Like

  14. […] on the results page. You might even be able to do that in the s_doPlugins() method in the s_code.js file. Check where you are setting the “Searches” event (usually event1 or event2) and add […]

    Like

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

    Like

  16. […] won’t have to touch the image request, though. The web analytics system will provide a JS library that takes care of the low-level programming and gives you access to a high-level object with all […]

    Like

  17. […] to the closing </body> tag. Down there, you first load the JS file that does all the setup (s_code.js), then you’ll add a <script> block that allows you to assign a name to the page. […]

    Like

  18. […] Within those handlers, all you need to do is write the name of the field that called it into your cookie. You can use the jQuery Cookie Plugin for that, or you can use a function called s.c_w() that comes with the s_code.js. […]

    Like

  19. […] pretty straightforward: slice the s_code.js file, split it into […]

    Like

  20. […] the s_code.js file? It has a configuration section. In there, you’ll find a variable called […]

    Like

  21. […] about a year or so, I have always seen one specific article at the top of the list, The s_code.js File – Overview. This has always puzzled me slightly. It has often led to me thinking I should write about it some […]

    Like

  22. […] system pass the test (yes, often that means hard-coded values! putting s.campaign="test"; into the s_code.js file totally counts!). Once it passes, you refactor. Refactoring means removing programming sins, […]

    Like

  23. […] is the equivalent of setting the old s_account variable in your s_code.js or AppMeasurement.js […]

    Like

  24. […] a refresher, the doPlugins method is defined inside the s_code.js or AppMeasurement.js file. It is a callback method that allows for a considerable amount of […]

    Like

  25. […] am so used to tag management by now, that when I see how popular the mini-series on the s_code.js file still is, I keep wondering why would people even look at that […]

    Like

  26. […] In the olden days[tm], this meant coming up with some version number yourself, then maintaining it, usually inside the s_code.js file. […]

    Like

  27. […] at the top, the s_code.js File – Overview with twice the views of the next, Reference – DTM Load Order. DTM Custom Event Rules is […]

    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: