_kmq.push(['record', name, properties, callback])

record records an event and its properties.

See the Pen KM JS Library - Record by Kissmetrics (@kissmetrics) on CodePen.

Parameters

NameTypeDescription
name*stringName of the event to be tracked.
propertiesobjectProperties related to the event being tracked.
callbackfunctionFunction to be called after the event is tracked.

_kmq.push(['trackClick', selector, name, properties])

trackClick tags an HTML element to record an event when it is clicked.

See the Pen KM JS Library - Track Click by Kissmetrics (@kissmetrics) on CodePen.

Parameters

NameTypeDescription
selector*stringThe ID or class of the element to track.
name*stringThe name of the event to record.
propertiesobjectProperties related to the event being recorded.

_kmq.push(['trackClickOnOutboundLink', selector, name, properties])

trackClickOnOutboundLink tags a link that takes someone to another domain and provides enough time to record an event when the link is clicked, before being redirected.

This builds in time to send the event by:

Canceling the original click event’s default behavior
Sending the data to Kissmetrics
Waiting 250ms
Redirecting the browser by setting document.location
For this reason we don’t recommend this for usual click tracking. Please make sure to test this with your site so that this performs as expected.

<a href="http://othersite.com" id="link1">Visit Other Site</a>
<script type="text/javascript">
  _kmq.push(['trackClickOnOutboundLink', 'link1', 'Visited Other Site']);
</script>

Parameters

NameTypeDescription
selector*stringThe ID or class of the link to tag.
name*stringThe name of the event to record.
propertiesobjectProperties related to the event being recorded.

_kmq.push(['trackSubmit', selector, name, properties])

trackSubmit tags a form to record an event when it is submitted.

_kmq.push(['trackSubmit', '.contact-form', 'Submitted Contact Form', { company: 'Kissmetrics'}]);

Parameters

NameTypeDescription
selector*stringThe ID or class of the form to tag.
name*stringThe name of the event to record.
propertiesobjectProperties related to the event being recorded.

Automatically Tracked Events

The JavaScript library automatically tracks certain events and properties by default - meaning as soon as you insert the snippet into your pages, you will automatically start sending data to Kissmetrics:

  • Visited Site
    • The Property KM Referrer indicates the URL the visitor came from
    • The Property URL indicates the URL of the page they started browsing your site
    • We record Visited Site once for each visitor’s browsing session. After 30 minutes of inactivity, the next time the visitor comes back will trigger a new Visited Site event, and they will also have the km_returning property set to “Returning”.
    • km_returning is a built-in property that we calculate based on when the user recorded “Visited Site.” The first time a user visits your site, km_returning will be set to “new.” On every subsequent visit, km_returning will be set to “returning.”
  • Form Fields
    • If you set up an event to log a form submission (either through the API call trackSubmit or the Event Library’s ‘Submits a Form’), then we also capture the data from the form’s fields.
    • Each <input> field will be saved as Property; we use the name attribute of the <input>’s to name each Property.
    • Sensitive fields (passwords, credit card numbers, and social security numbers) are NOT captured.
  • Ad Campaign Hit
    • Triggered if a visitor reaches your site via a Google Ad Campaign (eg. paid search). We detect this by checking the URL for ?gclid or ?utm_ parameters, which indicate a URL tagged for ad purposes.
    • All the utm variables will be captured as properties, if they are present in the URL.
      • Campaign Source
      • Campaign Medium
      • Campaign Terms
      • Campaign Content
      • Campaign Name
  • Search Engine Hit
    • Triggered if a visitor reaches your site via a search engine, through organic search.
    • The Property Search Engine indicates which search engine was used.
    • The Property Search Terms indicates the search terms used.
  • Page Views
    • (disabled by default!)
    • Triggered every time a visitor views any page on your site.
    • The Property Viewed URL indicates the page viewed.
    • The Property KM Previous Page indicates the page last viewed.

View all the events here: https://app.kissmetrics.com/product.js_settings. You can enable/disable these events on this page, too.