PageSourceSearch

https://www.georgiaaquarium.org/wp-content/plugins/tessitura-gai/js/return-tracker.js?ver=20261001185940

js georgiaaquarium.org collected 2026-10-02 09:50:28 UTC 4,663 bytes, 120 lines download raw bytes

1var gaiReturnTracker = (function($) {
2
3    var t = {};
4
5    t.COOKIE_NAME = 'gaq_return_to';
6
7    // Auth-flow and order-confirmation pages: never worth remembering as a "return to" destination.
8    t.EXCLUDED_PATH_PREFIXES = ['/login', '/pass-login', '/register', '/forgot-password', '/order', '/account'];
9
10    t.cookieDomain = function() {
11        return (env.live ? '.georgiaaquarium.org' : '');
12    };
13
14    t._debug = function(msg, data) {
15        if (env.live) { return; }
16        console.log('[RETURN-TRACKER] ' + msg, data !== undefined ? data : '');
17        //alert('[RETURN-TRACKER] ' + msg + (data !== undefined ? ' ' + data : ''));
18    };
19
20    // Only worth logging when there was actually something to clear — otherwise
21    // an already-empty tracker would re-announce "cleared" on every single page load
22    // (e.g. for a logged-in user browsing many pages in a row).
23    t._clearWithDebug = function(msg) {
24        if (t.get()) {
25            t._debug(msg);
26        }
27        t.clear();
28    };
29
30    // Reuses utils.js's global `inTNEW` when present, but computes it the same way as a
31    // fallback so this still works if this script is ever delivered standalone (e.g. via
32    // GTM) onto the actual TNEW domain, where utils.js won't be loaded.
33    t._isOnTNEW = function() {
34        if (typeof inTNEW !== 'undefined') { return inTNEW; }
35        return (window.location.host.indexOf('tnhs') !== -1) || (window.location.host.indexOf('tickets.georgiaaquarium.org') !== -1);
36    };
37
38    // On TNEW itself, our WP-side session cookie can't be trusted to reflect a login/logout
39    // that just happened there, so we read GTM's dataLayer instead — the most recent pushed
40    // entry with a `session.customer` property, non-zero meaning logged in.
41    t._isLoggedInViaDataLayer = function() {
42        var dl = window.dataLayer;
43        if (!Array.isArray(dl)) { return false; }
44        for (var i = dl.length - 1; i >= 0; i--) {
45            var entry = dl[i];
46            if (entry && entry.session && (typeof entry.session.customer !== 'undefined')) {
47                return !!Number(entry.session.customer);
48            }
49        }
50        return false;
51    };
52
53    // Same "named constituent" signal session.js already uses elsewhere (reboundCheck) to
54    // toggle the logged-in nav state. An already-logged-in user isn't going through the
55    // reset-then-login flow this tracker exists for, so it should stay off for them.
56    t.isLoggedIn = function() {
57        if (t._isOnTNEW()) {
58            return t._isLoggedInViaDataLayer();
59        }
60        return !!(typeof Tession !== 'undefined' && getCookie(Tession.NAME_COOKIE));
61    };
62
63    t._isExcludedPath = function(path) {
64        return t.EXCLUDED_PATH_PREFIXES.some(function(prefix) {
65            return path.indexOf(prefix) === 0;
66        });
67    };
68
69    t._stash = function(url) {
70        setCookie(t.COOKIE_NAME, url, false, true, t.cookieDomain());
71        t._debug('Stashed destination:', url);
72    };
73
74    // Called on ordinary page loads. Only stashes when the current page isn't an auth-flow
75    // page, the user isn't already logged in, and the purchase-complete case hasn't fired.
76    t.maybeRecordCurrentPage = function() {
77        if (t.isLoggedIn()) {
78            t._clearWithDebug('User already logged in, clearing tracker.');
79            return;
80        }
81
82        if ((window.location.pathname.indexOf('/order') === 0) && (getURLParameter('purchaseStatus') === 'complete')) {
83            t._clearWithDebug('Purchase complete, clearing tracker.');
84            return;
85        }
86
87        if (t._isExcludedPath(window.location.pathname)) {
88            t._debug('Skipping stash, excluded path:', window.location.pathname);
89            return;
90        }
91        t._stash(window.location.href);
92    };
93
94    // Called right before a JS-driven redirect to TNEW, so we don't lose the destination
95    // once we cross the domain boundary and this script stops running.
96    t.recordDestination = function(url) {
97        if (t.isLoggedIn()) {
98            t._clearWithDebug('User already logged in, clearing instead of recording destination: ' + url);
99            return;
100        }
101        t._stash(url);
102    };
103
104    t.get = function() {
105        return getCookie(t.COOKIE_NAME);
106    };
107
108    // Domain-aware deletion — must match the domain attribute the cookie was set with,
109    // otherwise the browser leaves the scoped cookie in place and creates an unrelated host-only one.
110    t.clear = function() {
111        setCookie(t.COOKIE_NAME, '', -1, true, t.cookieDomain());
112    };
113
114    return t;
115
116})(jQuery);
117
118jQuery(function() {
119    gaiReturnTracker.maybeRecordCurrentPage();
120});

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.