PageSourceSearch

https://arecruta.com.br/blog-analytics.js?v=20261001

js arecruta.com.br collected 2026-10-02 01:17:35 UTC 5,856 bytes, 108 lines download raw bytes

1/* Blog measurement uses the site's public configuration and shared consent cookie. */
2(function () {
3  'use strict';
4  if (window.BlogAnalytics) return;
5  var config = {}, googleReady = false, metaReady = false, googleSent = false, metaSent = false;
6  var choice = readConsent();
7  var bar = document.getElementById('blogConsentBar');
8  var preference = document.querySelector('[data-blog-cookie-settings]');
9  window.dataLayer = window.dataLayer || [];
10  window.gtag = window.gtag || function () { window.dataLayer.push(arguments); };
11  window.gtag('consent', 'default', { analytics_storage: 'denied', ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied' });
12  window.gtag('set', 'ads_data_redaction', true);
13
14  function readConsent() {
15    var entry = document.cookie.split('; ').find(function (part) { return part.indexOf('rd_marketing_consent=') === 0; });
16    return entry ? entry.slice('rd_marketing_consent='.length) : '';
17  }
18  function saveConsent(value) {
19    var domain = /(^|\.)arecruta\.com\.br$/.test(location.hostname) ? '; Domain=arecruta.com.br' : '';
20    document.cookie = 'rd_marketing_consent=' + value + '; Path=/; Max-Age=2592000; SameSite=Lax' + (location.protocol === 'https:' ? '; Secure' : '') + domain;
21  }
22  function permitted() { return choice === 'all' && readConsent() === 'all'; }
23  function metadata() {
24    var referrer = '';
25    try { referrer = document.referrer ? new URL(document.referrer).origin : ''; } catch (_) {}
26    var article = /^\/blog\/([a-z0-9-]+)\/?$/.exec(location.pathname);
27    var heading = document.querySelector('h1');
28    var category = document.querySelector('.article-hero .category-tag');
29    return {
30      page_location: location.origin + location.pathname,
31      page_referrer: referrer,
32      page_title: heading ? heading.textContent.trim() : 'Blog Recruta',
33      content_group: 'blog',
34      article_slug: article ? article[1] : 'hub',
35      article_category: category ? category.textContent.trim() : 'todos'
36    };
37  }
38  function metaSafe() {
39    // Meta reads the browser URL itself. Suppress it on arbitrary query/search input.
40    var allowed = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'fbclid', 'gclid'];
41    var hash = location.hash.slice(1);
42    if (hash && !/^cat=(all|radar|ia|agenda|mercado|pcd|outplacement|imprensa)$/.test(hash) && !(/^[a-z0-9_-]+$/.test(hash) && document.getElementById(hash))) return false;
43    return !Array.from(new URLSearchParams(location.search)).some(function (entry) {
44      return allowed.indexOf(entry[0]) < 0 || !/^[a-zA-Z0-9_.|-]{1,160}$/.test(entry[1]);
45    });
46  }
47  function load(src) {
48    var script = document.createElement('script'); script.async = true; script.src = src;
49    document.head.appendChild(script);
50  }
51  function initialize() {
52    if (!permitted()) return;
53    if (!googleReady && /^G-[A-Z0-9]+$/.test(config.ga4Id || '') && !config.ga4Id.includes('XXXX')) {
54      googleReady = true;
55      var data = metadata();
56      window.gtag('set', 'page_location', data.page_location);
57      window.gtag('set', 'page_referrer', data.page_referrer);
58      load('https://www.googletagmanager.com/gtag/js?id=' + config.ga4Id);
59      window.gtag('js', new Date());
60      window.gtag('config', config.ga4Id, Object.assign({}, data, { send_page_view: false, allow_google_signals: false, allow_ad_personalization_signals: false }));
61    }
62    if (googleReady && !googleSent) {
63      googleSent = true;
64      window.gtag('event', 'page_view', Object.assign(metadata(), { send_to: config.ga4Id }));
65    }
66    if (!metaReady && metaSafe() && /^\d+$/.test(config.metaPixelId || '')) {
67      metaReady = true;
68      if (!window.fbq) {
69        var fbq = function () { fbq.callMethod ? fbq.callMethod.apply(fbq, arguments) : fbq.queue.push(arguments); };
70        fbq.queue = []; fbq.push = fbq; fbq.loaded = true; fbq.version = '2.0'; window.fbq = fbq; window._fbq = fbq;
71        load('https://connect.facebook.net/en_US/fbevents.js');
72      }
73      window.fbq('set', 'autoConfig', false, config.metaPixelId);
74      window.fbq('init', config.metaPixelId);
75    }
76    if (metaReady && metaSafe()) {
77      window.fbq('consent', 'grant');
78      if (!metaSent) {
79        metaSent = true;
80        window.fbq('trackSingle', config.metaPixelId, 'PageView', { content_name: metadata().page_title, content_category: 'blog' });
81      }
82    }
83  }
84  function setConsent(value) {
85    choice = value === 'all' ? 'all' : 'essential';
86    saveConsent(choice);
87    var state = choice === 'all' ? 'granted' : 'denied';
88    window.gtag('consent', 'update', { analytics_storage: state, ad_storage: state, ad_user_data: state, ad_personalization: state });
89    if (bar) bar.hidden = true;
90    if (choice === 'all') initialize();
91    else if (window.fbq) window.fbq('consent', 'revoke');
92  }
93  window.BlogAnalytics = {
94    setConsent: setConsent,
95    status: function () { return { consent: choice, googleConfigured: !!config.ga4Id, metaConfigured: !!config.metaPixelId, googleInitialized: googleReady, metaInitialized: metaReady }; }
96  };
97  if (bar) {
98    bar.hidden = choice === 'all' || choice === 'essential';
99    bar.querySelectorAll('[data-blog-consent]').forEach(function (button) {
100      button.addEventListener('click', function () { setConsent(button.getAttribute('data-blog-consent')); if (preference) preference.focus(); });
101    });
102  }
103  if (preference) preference.addEventListener('click', function () { if (bar) { bar.hidden = false; bar.querySelector('button').focus(); } });
104  if (choice === 'all' || choice === 'essential') setConsent(choice);
105  fetch('/api/radar-config').then(function (response) { return response.ok ? response.json() : {}; }).then(function (data) {
106    config.ga4Id = data.ga4Id || ''; config.metaPixelId = data.metaPixelId || ''; initialize();
107  }).catch(function () {});
108})();

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.