Getting Started

Use a few lines of Javascript to specify the key events you want to track, based on your site’s URL structure, <body> CSS classes, or your own custom script.

Analyse your data - including all SiteHound events and properties - via Mixpanel or any tool you have connected via Segment.

If you already have tracking set up

SiteHound is compatible with your existing tracking - installing the library should have no adverse effects, and will automatically enhance your existing events with additional properties in addition to the events it tracks automatically.

Installing SiteHound

To install SiteHound, you just need to add some Javascript to the <head> of your website.

If you use a tag manager, you can paste the scripts below into a custom HTML tag.

You can use the same scripts (snippets and configuration) on all pages of your site.

1 - Add the Segment.com snippet

SiteHound relies on the Segment.com snippet to send data to your analytics tooling, so ensure that’s included first:

Copy/paste the snippet from the Segment.com web interface setup page.

The snippet looks like the example below.

Ensure the API key for the correct project is filled out in the call to analytics.load().

3. Add config for your site & trigger the tracking when done

<script type="text/javascript">// add rules for key pages we wish to tracksitehound.trackPages={'Home':'/',// use arrays match any of multiple criteria:'Page type':['/string/matches/full/url/path',/^\/regex\/matches\/multiple\/url\/paths\//,'.css_class_on_html_body_element']// NB. use URL matching where possible, since this can also be applied to referrers};// track "Viewed Unidentified Page" event for all pages not covered abovesitehound.trackAllPages=true;// enable logging informational messages to the consolesitehound.logToConsole=true;// after all config, trigger the tracking for this pagesitehound.sniff();</script>

4 - Use methods to track your custom events

This passes events through to Segment, ensuring they have all the appropriate traits added by the library.

// track an event, a la analytics.track()sitehound.track(name,[traits]);// as per track(), but count the number of occurences in a propertysitehound.trackAndCount(name,[traits]);// as per track(), but only track this event once per sessionsitehound.trackOnce(name,[traits]);// as per analytics.trackLink(), wrapped to pass relevant traits for this pagesitehound.trackLink(link_elements,event_name,[traits]);// as per analytics.trackForm(), wrapped to pass relevant traits for this pagesitehound.trackForm(form_elements,event_name,[traits]);

Meta-tracking: tracking info, warnings and errors about our tracking

If useful, you can make use of the following methods to track things that go wrong or unexpected events for further investigation: