javascripttagsweb-analyticsadobe-analyticsweb-analytics-tools

Automatic SiteCatalyst s_code call in-page and by DTM



I'm keeping a doubt about what, inside SiteCatalyst s_code, exactly fires the first automatic call on the page load.

In fact, I faced two different scenarios that made me a little confused.
Usually, the s_code library is gone with a page-bottom code that figures like the one below:

<!-- SiteCatalyst code version: H.26.0.
Copyright 1996-2011 Adobe, Inc. All Rights Reserved
More info available at http://www.omniture.com -->
<script language="JavaScript" type="text/javascript" src="path_to/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. */
/************* 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><img src="http://metrics...." height="1" width="1" border="0" alt=""/></noscript><!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst code version: H.26.0. --><br/><br/>

I ended up that this part: var s_code=s.t();fires the first automatic call (via the t() method) but I'm wondering why the if(s_code)document.write(s_code) is needed.
Removing these two directives would result in stopping any automatic call on the page load.

When s_code is served by the DTM, instead, seems to fire the first call without the page-bottom code, just by the s_code library loading.
Both the stand-alone s_code and the DTM one are H.x versions.

So my final questions are:
- Why this part var s_code=s.t();if(s_code)document.write(s_code) is needed at the page-bottom?
- Exactly what fires the automatic s_code call ?
Thanks a lot.


Solution

  • s.t() is the actual "trigger" that builds the request URL and in most cases, also makes the request. However, very old versions of IE (that nobody actually cares about anymore), it could not make the request by virtue of making the img object. So, the extra code to document.write was added, to cater to those very old versions of IE (that nobody actually cares about anymore).

    So, unless you really still want to cater to very old versions of IE (we're talking IE1-IE4), the on-page code can be reduced to:

    <script language="JavaScript" type="text/javascript" src="path_to/s_code.js"></script>
    <script language="JavaScript" type="text/javascript">
    /* custom vars here */
    
    /* end custom vars */
    s.t();
    </script>
    

    With DTM on the other hand, you have the "top" code which is the script include, and then the "bottom" code which is the _satellite.pageBottom() call.

    Then, when you implement Adobe Analytics as a tool (whether you configure DTM to handle the library automatically, or if you want to put the library code in the code box yourself, or host it in your own location), DTM will make the s.t() call itself.

    When DTM actually makes the s.t() call depends on whether you configure it to trigger at top of page or bottom of page.