PageSourceSearch

https://www.marktplaats.nl/i/chatbot-mara/js/analyticsService.js

js marktplaats.nl collected 2026-09-24 08:26:56 UTC 1,545 bytes, 54 lines download raw bytes

1/**
2 * AnalyticsService
3 * Handles dispatching of Google Analytics and custom tracking events.
4 */
5export class AnalyticsService {
6    constructor(component) {
7        this.component = component;
8        this.trackEventName = '';
9    }
10
11    setTrackEventName(name) {
12        this.trackEventName = name;
13    }
14
15    getTrackEventName() {
16        return this.trackEventName;
17    }
18
19    dispatchGaEvent(category, action) {
20        const label = this.computeEventLabel();
21        this.component.dispatchEvent(new CustomEvent('CustomActionTrackingEvent', {
22            detail: {
23                eventName: action,
24                eventDetail: { event_category: category, event_label: label, value: 1 }
25            },
26            bubbles: true,
27            composed: true
28        }));
29        this.trackEventName = '';
30    }
31
32    dispatchAnalytics(category, action) {
33        this.component.dispatchEvent(new CustomEvent('chatanalytics', {
34            detail: { category, action },
35            bubbles: true,
36            composed: true
37        }));
38    }
39
40    computeEventLabel() {
41        try {
42            const url = decodeURIComponent(window.location.href);
43            const path = url.split('/s/')[1];
44            if (!path) return '/';
45            if (path.includes('global-search')) return 'search/';
46
47            const [label] = path.split('/');
48            const suffix = path.substring(path.lastIndexOf('/'));
49            return label + (suffix.endsWith('chat=1') ? '/' : suffix);
50        } catch {
51            return '/';
52        }
53    }
54}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.