Tracking Methods
setConsent()
Sets user consent for tracking and cookie usage.
Syntax
window.MarketFit.setConsent(consentType, granted)Parameters
consentTypestring (required): Consent type (‘analytics’, ‘marketing’, ‘functional’)grantedboolean (required): If consent was granted
Example
// Grant consent for analytics
window.MarketFit.setConsent('analytics', true);
// Revoke consent for marketing
window.MarketFit.setConsent('marketing', false);trackEvent()
Records custom events for analysis and tracking.
Syntax
window.MarketFit.trackEvent(eventName, properties)Parameters
eventNamestring (required): Name of the event to recordpropertiesobject (optional): Additional event properties
Example
// Record interaction event
window.MarketFit.trackEvent('button_click', {
button_name: 'pricing_cta',
page: '/pricing',
user_type: 'visitor'
});
// Record conversion event
window.MarketFit.trackEvent('conversion', {
type: 'lead_generation',
value: 100,
campaign: 'summer_promo'
});trackPageView()
Records a page view for navigation tracking.
Syntax
window.MarketFit.trackPageView(pageData)Parameters
pageDataobject (optional): Additional page data
Example
// Record basic page view
window.MarketFit.trackPageView();
// With additional data
window.MarketFit.trackPageView({
page_title: 'Pricing Page',
page_category: 'commercial',
user_segment: 'enterprise'
});consent
Object handling user consent for cookies and tracking.
Properties
const consent = window.MarketFit.consent;
// Available properties
consent.consentGranted // boolean: general consent
consent.categories // object: consent categories
consent.forceShow // boolean: force show bannerExample
// Verify consent state
console.log('Consent granted:', window.MarketFit.consent.consentGranted);
console.log('Categories:', window.MarketFit.consent.categories);Last updated on