Skip to content

TrackIt Plugin CheckUrlMapping

sdasilva edited this page Sep 14, 2010 · 2 revisions

This plugin is available as part of the minified package and can be referenced by adding TrackItPlugins.CheckUrlMapping to the TrackIt Options.

var options = {
    XmlUrl: "/Assets/xml/trackItData.xml",
    Plugins: [ 
        $.TrackItPlugins.CheckUrlMapping 
    ],
     Data: { 
        "Homepage Load": {
             urlMap: "/|/index.html",
             type: "pageView"
             pageName: "Homepage"
        }
    }
};

The CheckUrlMapping Plugin allows you to fire a trackEvent based on a regular expression against the URL. This makes it very simple to fire numerous page load events without having to inject page specific code.

This plugin extends the TrackIt Data by adding a new urlMap attribute on a trackEvent. This looks like the following:

<trackEvents>
   <trackEvent key=“Homepage Load” event=“pageView” urlMap=“/”>
       <pageName>Homepage</pageName>
       <channel>Home</channel>
   </trackEvent>
</trackEvents>

The urlMap attribute can also listen on multiple url’s by separating each URL with a pipe or vertical bar, e.g. |. So if my homepage also lived at /index.html and /, I could modify the above example as such:

<trackEvents>
   <trackEvent key=“Homepage Load” event=“pageView” urlMap=“/|/index.html”>
       <pageName>Homepage</pageName>
       <channel>Home</channel>
   </trackEvent>
</trackEvents>