Documentation / Product / Features / Lytics JavaScript Tag / Using Version 3

Collecting Data

The Lytics JavaScript tag makes collecting behavioral data about your website visitors easy. By installing our tag, you will automatically begin to collect page-level information such as URL, referrals, and browser data. This is what ultimately unlocks the power of a user’s content affinity. In addition to page-level data, custom data can be collected to further expand user profiles and support use cases.

NOTE: Please ensure that you have access to an experienced JavaScript developer. Though most installations are straight forward, Lytics Support may not be able to make recommendations or provide troubleshooting assistance as we do not have domain knowledge or access to your web property's unique source code.

Table of Contents

What data is collected?

The following raw fields are included along with any collect event managed by the Lytics JavaScript tag.

KeySample ValueDescription
_epvThe type of event responsible for the event emission. pv for example represents a page view
_refwww.lytics.comThe referral domain.
_tz-7An integer representation of the user's time zone. Integer represents the difference between current time and standard UTC time. PST for example would be -7
_ulen-USThe user's language as derived from the browser.
_sz2560x1440The size of the user's display.
_ts1504306728695The current time represented by milliseconds since Unix Epoch.
_nmobtIf the page is being consumed on a mobile device or not. _nmob:true represents not mobile
_devicedesktopThe users current device type.
urlwww.getlytics.comThe URL where the data was sent from.
_uid74481.3222228897The users Lytics _uid or cookie ID.
_v3.0.2Version number of the JavaScript tag that sent the data.

Page Views

By default, an initial page view will be captured each time the browser fully loads a new URL. This ensures that you are collecting the base behavior out-of-the-box. Alternatively, you can capture a page view manually at any point during a session by calling the pageView method.

jstag.pageView();

Events

In addition to page views, the Lytics tag makes collecting arbitrary custom events easy. This is useful when it comes to user actions such as clicks, form submissions, purchases, etc. Regardless of the reason for collecting, the send method can be leveraged to pass any valid JavaScript object to Lytics.

jstag.send({name:"Jon"});

In the above example we are simply passing the key of name to Lytics with a value of Jon to the default data stream. Of course, this is a basic example and something more realistic might be represented by the following examples.

Example User Data

jstag.send({
  userid: "1234",
  facebook_id: "abc123",
  twitter_id: "def123",
  linkedin_id: "hij123",
  email: "[email protected]",
  name: "Jon Snow",
  first_name: "Jon",
  last_name: "Snow",
  title: "King in the North",
  company: "House Stark",
  phone: "555-555-5555",
  cell: "555-555-5555",
  age: 21,
  gender: "m",
  city: "Winterfell",
  state: "Westeros",
  country: "IE",
  zip: "55555",
  origin: "organic",
  status: "known"
});

Example Conversion Data

jstag.send({
  event: "conversion",                
  campaign_id: "someconversionid",    
  variation_id: "somevariationid",    
  currency: "USD",                    
  value: 25.99                        
});

Example Event Data

jstag.send({
  event: "rescued sansa"
});

Advanced Options

In addition to a JavaScript object payload, all Lytics JavaScript tag collection methods accept three optional parameters. These should only be implemented by advanced users who fully understand the implications of using custom streams within Lytics or require feedback on asynchronous actions.

OptionTypeDescriptionExample
STREAMstringThe name of the Lytics stream collected data should be sent to.jstag.send('mystream');
PAYLOADobjectThe JavaScript object you want to send to Lytics.jstag.send({name:'Jon', state:'Westeros'})
CALLBACKfunctionThe JavaScript function to be called once collect completes.jstag.send('mystream', {name:'Jon'}, function(r){console.log(r);})
jstag.send(STREAM, PAYLOAD, CALLBACK);
jstag.pageView(STREAM, PAYLOAD, CALLBACK);