Quantcast
Channel: s_code.js – Web Analytics for Developers
Viewing all 46 articles
Browse latest View live

Tracking 404 Error Pages

$
0
0

There are tools out there that find bogus links on your site, and some even try to find links outside your site that point to nirvana. But your friendly marketer likely wants to have better data than that, so she asks you to build tracking for 404 pages.

Now what?

Let me explain, both for Javascript-only (“legacy”) and DTM-based deployments.

Javascript-only

If your site is not yet using a TMS, or if your TMS wants you to write Javascript code for Analytics, then you should read this part.

What we need:

  • a 404 error handler page
  • the Analytics library loaded on that page (either s_code.js or AppMeasurement.js)
  • a limited data layer on the 404 handler page
    1. stating it is the 404 handler page
    2. carrying the original URL that failed
  • a little Javascript block at the bottom of the page

There is a special report for pages that do not exist, aptly called the “Pages not Found” report. For a not-found page to show up in this report, its URL has to be tracked, and the system has to be told that this URL was bad.

Here’s what that would look like:

	s.pageName = "404:" + window.location.href;
	s.pageType = "errorPage"; // this makes it a call for the Pages not Found report
	s.t();

The two things to note here are:

  1. Setting s.pageType = "errorPage" is what makes this call special. By setting this, you tell Analytics that the page name should be treated like a URL for the Pages not Found report.
  2. Setting s.pageName, you should include the original URL. That’ll help you figure out where the problem is. Whether you use window.location.href, window.location.pathname, or something else, is entirely up to you.

Note that the s.pageType Variable is not used anywhere else! The above is the only use case and the only allowed value for that variable!

DTM-based

This will be pretty easy, too (so I wrote it first). We need:

  • a 404 error handler page
  • a limited data layer on the 404 handler page
    1. stating it is the 404 handler page
    2. carrying the original URL that failed
  • one Page Load Rule
  • a little bit of custom Javascript inside that rule

To show you an example, here’s what happens if you go to — say — https://www.jan-exner.de/blablabla:

[screenshot]

Data Layer on the 404 handler page

The resulting tracking call looks like this:

[screenshot]

Analytics tracking call on 404 page

And in Analytics, you’ll later see this:

[screenshot]

Analytics Pages not Found report

How did I do that? Easy. Here is the PLR:

[screenshot]

Page Load Rule for 404 page

And the custom code is actually a single line:

[screenshot]

Custom Code inside the PLR

Want to see the httpErrorCode Data Element, too? Sure:

[screenshot]

Data Element for 404 error tracking

Any questions?

Note that my 404 handler page is good in that it leaves the URL untouched, making it easy to create the pageName for tracking. Other content management systems redirect the browser. If yours does that, make sure the original URL is available somewhere in the page, so that it can be read and used for tracking.

Does it make sense to go one step further and track the referrer into a prop? I guess it does.


Filed under: AppMeasurement, DTM, Javascript, Page Code, Principles Tagged: analytics, appmeasurement.js, DTM, implementation, javascript, s_code.js, tag manager

The 2 Faces of the Audience Manager – Analytics Integration

$
0
0

So here you are, wondering. Your friendly marketer has told you to add a new tool to the toolbox — Adobe Audience Manager. She told you that you have to implement some code for it to work. You checked the help site and came away none the wiser. Let me help you. There are currently …

Continue reading The 2 Faces of the Audience Manager – Analytics Integration


Filed under: AppMeasurement, Automation, Integration, Javascript, Page Code Tagged: appmeasurement.js, audience manager, complexity, implementation, javascript, link tracking, s_code.js, tag manager

Cookies, IDs, and the Experience Cloud

$
0
0

In January 2008, when I joined a company called "Omniture" and started working as a consultant on a product called "SiteCatalyst", ìt (like most web analytics tools at the time) relied on cookies quite a lot. There was one cookie, specifically, which was important. It was called "s_vi", and it held what we called the …

Continue reading Cookies, IDs, and the Experience Cloud


Filed under: DTM, Integration Tagged: appmeasurement.js, complexity, DTM, implementation, javascript, simplicity, s_code.js, visitor ID

Out with the Old!

What is “s_code.js”? Do I have to know?

$
0
0

No. This could be the shortest post, ever. One word. These days, you really do not have to know what "s_code.js" is, and the only reason I am even writing this is because for some reason that totally eludes me, an old post about it, from back in 2013, keeps being the most or second-most … Continue reading What is “s_code.js”? Do I have to know?

Adobe Experience Platform Web SDK

$
0
0

Last year, in April, I opined that a big change was coming for all of us who work with Analytics, Target, or Audience Manager. That change has been in the making for some time. I remember how Bret and Ben dropped some subtle hints some time ago in London. They were clearly exited, and, as … Continue reading Adobe Experience Platform Web SDK

Viewing all 46 articles
Browse latest View live