Skip to content
Login Contact

Custom dimensions tracking with the Marfeel SDK

Compass supports custom event tracking beyond default pageviews, giving you fine-grained control over how user interactions are recorded during navigation.

TIP
This feature is only available on the Enterprise Pricing Plan.

Custom variables are specific attributes of a user in the context of a page hit, the span of a session, or their lifecycle as a reader. Each variable type serves a distinct tracking scope.

Tracking page-specific actions or information by setting a page variable you can:

  • Measure pages that have been dynamically closed
  • Pages the user has played a video on
  • Pages the user has clicked on an affiliation link
  • Track response codes
  • Calculated metrics like PVs with >30% scroll

You can track pieces of information that stay unchanged for the whole duration of the user’s visit to your site to:

  • Track the number of closed pages a user has visited in a session
  • Track if the user has visited the pricing page
  • Consent Choice
  • Ad Blocking
  • Digital Wallet available

Use Marfeel’s user variables to add information specific to each reader:

  • Absolute number of hits to closed page views
  • Date of first visit
  • Days until subscription renewal
  • Has visited the subscription page
  • Has visited the home
  • CRM-like data: gender, age, interest groups, etc.

You can track as many events as you need, at any point during a user’s visit, even before the Marfeel SDK loads.

All events follow the same key-value pair model:

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.setPageVar('key', 'value');
compass.setSessionVar('key', 'value');
compass.setUserVar('key', 'value');
}]);

Where

  • setPageVar is used for actions where the current page is important, such as social sharing
  • setSessionVar is used to persist information at the visit or session level
  • setUserVar is used to persist user level information

Page variables track page-specific actions or information. Compass records a different value for each pageview.

Example: Track when a user shares the page

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.setPageVar('share', 'twitter');
}]);

Compass associates this variable with the current pageview.

A session variable stores information that stays unchanged for the whole duration of the user’s visit to your site.

Example: Track when a user subscribes to push notifications

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.setSessionVar('push', 'requested');
compass.setSessionVar('push', 'accepted');
compass.setSessionVar('push', 'rejected');
}]);

User variables add information specific to each reader. This information persists between visits, making it useful for long-term reader profiling.

Example: track readers subscribed to your push notifications.

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.setUserVar('push', 'subscribed');
}]);

A user segment is a specific group of readers who share similar characteristics, behaviors, or preferences. Segments can be defined based on demographics, browsing habits, or interaction with content. Passing user segments to Marfeel helps you analyze content performance, advertising, and user experiences across these distinct groups. Once tracked, custom variable dimensions become available for reporting in Compass.

Adds a new persistent user segment

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.addUserSegment('segment');
}]);

Replaces existing user segments

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.setUserSegments(['segment', 'segment2']);
}]);

Removes existing user segment

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.removeUserSegment('segment');
}]);

Clears all user segments

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
compass.clearUserSegments();
}]);

You can also track custom page metrics for numeric values like scroll depth or time on page.

What is the difference between page, session, and user variables in Compass?

Page variables (setPageVar) track actions tied to the current pageview, such as social sharing. Session variables (setSessionVar) persist for the duration of a single visit. User variables (setUserVar) persist across visits and store reader-specific information like subscription status or CRM data.

Can I track custom events before the Marfeel SDK loads?

Yes. You can queue custom dimension events at any point during a user visit, even before the Marfeel SDK finishes loading. All events use the same key-value pair model through the window.marfeel.cmd queue.

How do user segments work in Compass custom dimensions?

User segments group readers by shared characteristics, behaviors, or preferences. Compass provides methods to add a segment (addUserSegment), replace all segments (setUserSegments), remove a specific segment (removeUserSegment), or clear all segments (clearUserSegments). Segments persist across visits.