PageSourceSearch

https://simpleprogrammer.com/wp-content/mu-plugins/sp-growth-events.js?ver=1.2.0

js simpleprogrammer.com collected 2026-10-01 10:36:19 UTC 4,321 bytes, 154 lines download raw bytes

1(function () {
2  'use strict';
3
4  window.dataLayer = window.dataLayer || [];
5
6  function push(eventName, details) {
7    window.dataLayer.push(Object.assign({
8      event: eventName,
9      page_path: window.location.pathname
10    }, details || {}));
11  }
12
13  function cleanUrl(url) {
14    return url.origin + url.pathname;
15  }
16
17  function cleanSlug(value) {
18    return value ? String(value).replace(/[^A-Za-z0-9_-]/g, '').slice(0, 80) : '';
19  }
20
21  function sourceArticle() {
22    if (window.location.pathname.indexOf('/rdu/') !== 0) return '';
23
24    try {
25      return cleanSlug(new URLSearchParams(window.location.search).get('from'));
26    } catch (_) {
27      return '';
28    }
29  }
30
31  function sourceVariant() {
32    if (window.location.pathname.indexOf('/rdu/') !== 0) return '';
33
34    try {
35      return cleanSlug(new URLSearchParams(window.location.search).get('cta_variant'));
36    } catch (_) {
37      return '';
38    }
39  }
40
41  function attributeRduDestination(anchor) {
42    var slug = sourceArticle();
43    var variant = sourceVariant();
44    if (!slug || !anchor || !anchor.href) return;
45
46    try {
47      var url = new URL(anchor.href, window.location.href);
48      if (url.hostname !== 'accelerator.simpleprogrammer.com' ||
49          url.pathname.indexOf('/free-video') !== 0) {
50        return;
51      }
52
53      url.searchParams.set('utm_source', 'simpleprogrammer');
54      url.searchParams.set('utm_medium', 'article');
55      url.searchParams.set('utm_campaign', 'rdu_sp_article');
56      url.searchParams.set('utm_content', slug);
57      if (variant) url.searchParams.set('utm_term', variant);
58      anchor.href = url.toString();
59    } catch (_) {
60      // Attribution must never interrupt the visitor's navigation.
61    }
62  }
63
64  function attributeRduLinks() {
65    var links = document.querySelectorAll(
66      'a[href*="accelerator.simpleprogrammer.com/free-video"]'
67    );
68    Array.prototype.forEach.call(links, attributeRduDestination);
69  }
70
71  if (document.readyState === 'loading') {
72    document.addEventListener('DOMContentLoaded', attributeRduLinks);
73  } else {
74    attributeRduLinks();
75  }
76
77  document.addEventListener('click', function (event) {
78    var anchor = event.target.closest && event.target.closest('a[href]');
79    if (!anchor) return;
80
81    attributeRduDestination(anchor);
82
83    var url;
84    try {
85      url = new URL(anchor.href, window.location.href);
86    } catch (_) {
87      return;
88    }
89
90    var details = {
91      link_url: cleanUrl(url),
92      link_domain: url.hostname,
93      link_text: (anchor.textContent || '').trim().slice(0, 100)
94    };
95
96    if (/^(www\.)?amazon\./i.test(url.hostname) || url.hostname === 'amzn.to' || url.hostname === 'a.co') {
97      details.affiliate_program = 'amazon';
98      details.affiliate_tag = url.searchParams.get('tag') || '';
99      push('affiliate_click', details);
100      return;
101    }
102
103    if (/thrivecart\.com$/i.test(url.hostname)) {
104      details.checkout_provider = 'thrivecart';
105      push('checkout_start', details);
106      return;
107    }
108
109    if (url.origin === window.location.origin && url.pathname.indexOf('/level-up/') === 0) {
110      push('level_up_cta_click', details);
111      return;
112    }
113
114    if (url.origin === window.location.origin && url.pathname.indexOf('/products/') === 0) {
115      push('owned_product_cta_click', details);
116      return;
117    }
118
119    if (url.origin !== window.location.origin && /^https?:$/.test(url.protocol)) {
120      push('outbound_click', details);
121    }
122  }, true);
123
124  document.addEventListener('submit', function (event) {
125    var form = event.target;
126    if (!form || !form.action) return;
127
128    try {
129      var action = new URL(form.action, window.location.href);
130      if (/getdrip\.com$/i.test(action.hostname)) {
131        push('drip_opt_in_submit', { form_provider: 'drip' });
132      }
133    } catch (_) {
134      // Invalid form actions are ignored; never interrupt the visitor's submission.
135    }
136  }, true);
137
138  window.addEventListener('message', function (event) {
139    var hostname;
140    try {
141      hostname = new URL(event.origin).hostname;
142    } catch (_) {
143      return;
144    }
145
146    if (!/(^|\.)leadconnectorhq\.com$/i.test(hostname) ||
147        !Array.isArray(event.data) ||
148        event.data[0] !== 'set-sticky-contacts') {
149      return;
150    }
151
152    push('newsletter_opt_in_submit', { form_provider: 'gohighlevel' });
153  });
154}());

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.