### Mark Shopify Header Content Load Start Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This JavaScript snippet uses the window.performance API to mark the start of the Shopify content loading process within the header. It helps in performance monitoring and debugging by providing a timestamp for when the header content begins to render. ```JavaScript window.performance && window.performance.mark && window. ``` -------------------------------- ### Initialize Shopify Trekkie Tracking Library in JavaScript Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This code initializes the 'trekkie' (Shopify Analytics library) object, defines its core methods ('identify', 'page', 'ready', 'track', etc.), and creates a factory function to dynamically generate method calls. This setup allows for deferred execution of tracking commands. ```javascript var trekkie = window.ShopifyAnalytics.lib = window.trekkie = window.trekkie || []; if (trekkie.integrations) { return; } trekkie.methods = [ 'identify', 'page', 'ready', 'track', 'trackForm', 'trackLink' ]; trekkie.factory = function(method) { return function() { var args = Array.prototype.slice.call(arguments); args.unshift(method); trekkie.push(args); return trekkie; }; }; for (var i = 0; i < trekkie.methods.length; i++) { var key = trekkie.methods[i]; trekkie[key] = trekkie.factory(key); } ``` -------------------------------- ### Execute Trekkie Ready Callback and Integrate Google Analytics in JavaScript Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This snippet defines a callback that executes once the Trekkie library is ready. It reassigns 'window.ShopifyAnalytics.lib', temporarily overrides 'document.write' for Google Analytics integration, and then restores it. It also tracks page views and handles conversion logging. ```javascript var loaded = false; trekkie.ready(function() { if (loaded) return; loaded = true; window.ShopifyAnalytics.lib = window.trekkie; var originalDocumentWrite = document.write; document.write = customDocumentWrite; try { window.ShopifyAnalytics.merchantGoogleAnalytics.call(this); } catch(error) {}; document.write = originalDocumentWrite; window.ShopifyAnalytics.lib.page(null,{"pageType":"page","resourceType":"page","resourceId":92604924067,"shopifyEmitted":true}); var match = window.location.pathname.match(/checkouts\/(.+)\/(thank_you|post_purchase)/) var token = match? match[1]: undefined; if (!hasLoggedConversion(token)) { setCookieIfConversion(token); } }); var eventsListenerScript = document.createElement('script'); eventsListenerScript.async = true; eventsListenerScript.src = "//www.dfx" ``` -------------------------------- ### Initialize Shopify Analytics Meta Data in JavaScript Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This snippet initializes the 'window.ShopifyAnalytics' object and sets meta properties like currency and page details. It ensures that analytics data is correctly structured before tracking events. ```javascript tics = window.ShopifyAnalytics || {}; window.ShopifyAnalytics.meta = window.ShopifyAnalytics.meta || {}; window.ShopifyAnalytics.meta.currency = 'AUD'; var meta = {"page":{"pageType":"page","resourceType":"page","resourceId":92604924067}}; for (var attr in meta) { window.ShopifyAnalytics.meta[attr] = meta[attr]; } ``` -------------------------------- ### Initialize Google Tag Manager (GTM) Source: https://www.dfxparts.com.au/pages/diy-fork-valve-install-guide This standard JavaScript snippet initializes Google Tag Manager on the webpage. It creates a dataLayer array, pushes the GTM start event, and asynchronously loads the GTM script from Google's servers. This setup enables tracking and tag management through the GTM interface. ```JavaScript (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-MBV6PHN'); ``` -------------------------------- ### Initialize Google Tag Manager (GTM) Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This JavaScript snippet initializes Google Tag Manager (GTM) by pushing a 'gtm.start' event with the current timestamp to the dataLayer. It then asynchronously loads the GTM script from Google's servers, enabling comprehensive tracking and analytics functionalities through the configured GTM container. ```JavaScript (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-MBV6PHN'); ``` -------------------------------- ### JavaScript Shopify Analytics Replay Queue Initialization Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This snippet initializes the Shopify analytics object and sets up a replay queue for events. If `Shopify.analytics.replayQueue` is not already defined, it creates an empty array and defines a `publish` method that pushes event data into this queue. This ensures that analytics events are captured even if the full analytics library hasn't loaded yet. ```JavaScript (function e(e,d,r,n,o,i){if(void 0===i&&(i={}),!Boolean(null===(t=null===(a=window.Shopify)||void 0===a?void 0:a.analytics)||void 0===t?void 0:t.replayQueue)){var a,t;window.Shopify=window.Shopify||{};var s=window.Shopify;s.analytics=s.analytics||{};var l=s.analytics;l.replayQueue=[],l.publish=function(e,d,r){return l.replayQueue.push([e,d,r]),!0};try{self.performance.mark("wpm:start")}catch(e){}}})(); ``` -------------------------------- ### Initialize Shopify Analytics and Trekkie Ready Handler Source: https://www.dfxparts.com.au/collections/diy-drop-in-fork-valve-upgrade-kits/products/yamaha-xvs650-fork-upgrade-kit-1 This JavaScript snippet sets up the `trekkie` library's ready handler, ensuring that `window.ShopifyAnalytics.lib` is assigned to `window.trekkie` once the library is loaded. It also includes a mechanism to temporarily override `document.write` for Google Analytics integration. ```JavaScript var loaded = false; trekkie.ready(function() { if (loaded) return; loaded = true; window.ShopifyAnalytics.lib = window.trekkie; var originalDocumentWrite = document.write; document.write = customDocumentWrite; try { window.ShopifyAnalytics.merchantGoogleAnalytics.call(this); } catch(error) {}; document.write = originalDocumentWrite; // ... rest of the code for page/track events ... }); ``` -------------------------------- ### Initialize Shopify Trekkie Analytics Library Source: https://www.dfxparts.com.au/collections/diy-drop-in-fork-valve-upgrade-kits/products/yamaha-xvs650-fork-upgrade-kit-1 This snippet demonstrates the initialization pattern for Shopify's Trekkie analytics library. It defines the core methods (`identify`, `page`, `ready`, `track`, `trackForm`, `trackLink`) and uses a factory pattern to create corresponding functions, pushing arguments onto a queue. This setup allows for deferred execution of analytics commands. ```javascript var trekkie = window.ShopifyAnalytics.lib = window.trekkie = window.trekkie || []; if (trekkie.integrations) { return; } trekkie.methods = [ 'identify', 'page', 'ready', 'track', 'trackForm', 'trackLink' ]; trekkie.factory = function(method) { return function() { var args = Array.prototype.slice.call(arguments); args.unshift(method); trekkie.push(args); return trekkie; }; }; for (var i = 0; i < trekkie.methods.length; i++) { var key = trekkie.methods[i]; trekkie[key] = trekkie.factory(key); } trekkie.load = function(config) { trekkie.config = config || {}; trekkie.config.initialDocumentCookie = document.cookie; var first = document.getElementsByTagName('script')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.async = true; script.src = '//www.dfxparts.com.au/cdn/s/trekkie.storefront.7f48c99429cb25be36839f7a7bcca2ac8a69827d.min.js'; first.parentNode.insertBefore(script, first); }; ``` -------------------------------- ### Text: DIY Motorcycle Fork Valve Installation Guide Source: https://www.dfxparts.com.au/pages/diy-fork-valve-install-guide This step-by-step guide provides instructions for installing DFX drop-in fork valve kits. It covers essential preparation, removal of existing components, proper insertion of the new valve, setting the air gap, and final reassembly. Users are advised that specialized tools are required and the guide is unofficial. ```Text 1. Important: You will need to be able to fully extend and fully compress the forks. Make sure bike is suitably supported by jack or other means that is both stable and allows you to extend and compress the forks. 2. Cover any paintwork, floor and anything else you don't want oil on and have extra rags handy. Fork oil should not affect paint etc but it does make a mess. 3. With the forks fully extended (up), remove fork caps and any spacers/washers. 4. Remove fork springs slowly to avoid spillage (we told you to have rags handy) 5. Insert fork valve with bolt head down, lock nut up. Use a [claw or magnetic retrieval tool](https://www.repco.com.au/en/tools-equipment/hand-tools/miscellaneous/mechpro-3-piece-retrieval-tool-set-mps202k/p/A5427087?rgfeed=true&cid=google-shopping&utm_source=google&utm_medium=cpc&gclid=Cj0KCQjwvvj5BRDkARIsAGD9vlL3XdqfAA1A5pXvRUkWUfohQbGSHLxarICq5zd-rKdQ2r2DDqMahXAaArP6EALw_wcB) to "feel" that the valve has seated properly. 6. Set air gap. This is done with the forks fully compressed (down). DFX will often advise the exact air gap that you should have in your forks and what weight oil to use. If not, refer to service manual. 7. Replace fork springs. 8. Replace fork caps and any spacers/washers. 9. Ensure there is no oil on your tyre - or anywhere else it shouldn't be. 10. Go for a ride and enjoy, being sure to take it a bit easier than usual until you get used to the differences in the bike's handling. ``` -------------------------------- ### Configure Trekkie and Execute Ready Callback Source: https://www.dfxparts.com.au/pages/partners-installers This snippet applies the initial configuration to the `trekkie` library, including application details, shop ID, theme ID, and currency. It then defines a `trekkie.ready` callback that executes once the library is fully loaded. This callback handles critical post-load tasks like assigning the analytics library, temporarily overriding `document.write`, calling `merchantGoogleAnalytics`, and performing conversion tracking checks. ```javascript trekkie.load( {"Trekkie":{"appName":"storefront","development":false,"defaultAttributes":{"shopId":45696090275,"isMerchantRequest":null,"themeId":132974936227,"themeCityHash":"16954266077640314686","contentLanguage":"en","currency":"AUD"},"isServerSideCookieWritingEnabled":true,"monorailRegion":"shop_domain"},"Session Attribution":{},"S2S":{"facebookCapiEnabled":true,"source":"trekkie-storefront-renderer","apiClientId":580111}} ); var loaded = false; trekkie.ready(function() { if (loaded) return; loaded = true; window.ShopifyAnalytics.lib = window.trekkie; var originalDocumentWrite = document.write; document.write = customDocumentWrite; try { window.ShopifyAnalytics.merchantGoogleAnalytics.call(this); } catch(error) {}; document.write = originalDocumentWrite; window.ShopifyAnalytics.lib.page(null,{"pageType":"page","resourceType":"page","resourceId":92586639523,"shopifyEmitted":true}); var match = window.location.pathname.match(/checkouts\/(.+)\/(thank_you|post_purchase)/); var token = match? match[1]: undefined; if (!hasLoggedConversion(token)) { setCookieIfConversion(token); } }); ``` -------------------------------- ### Configure BSS Product Labels Pro App Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This JavaScript snippet initializes and configures the BSS Product Labels Pro application. It defines the API server endpoint, sets customer-specific data like tags and ID, and populates configuration arrays for banners and popups. This setup is crucial for the app's functionality in displaying product labels and managing its features. ```JavaScript if (typeof BSS_PL == 'undefined') { var BSS_PL = {}; } var bssPlApiServer = "https://product-labels-pro.bsscommerce.com"; BSS_PL.customerTags = 'null'; BSS_PL.customerId = 'null'; BSS_PL.configData = configDatas; BSS_PL.configDataBanner = configDataBanners ? configDataBanners : []; BSS_PL.configDataPopup = configDataPopups ? configDataPopups : []; BSS_PL.storeId = 24617; BSS_PL.currentPlan = "false"; BSS_PL.storeIdCustomOld = "10678"; BSS_PL.storeIdOldWIthPriority = "12200"; BSS_PL.apiServerProduction = "https://product-labels-pro.bsscommerce.com"; BSS_PL.integration = {"laiReview":{"status":0,"config":[]}} .homepage-slideshow .slick-slide .bss_pl_img { visibility: hidden !important; } function fixBugForStores($, BSS_PL, parent, page, htmlLabel) { return false;} ``` -------------------------------- ### JavaScript Initialize Shopify Analytics and Replay Queue Source: https://www.dfxparts.com.au/pages/diy-fork-valve-install-guide This function initializes the 'Shopify.analytics' object, creating a 'replayQueue' array and a 'publish' method. The 'publish' method pushes event data into the 'replayQueue', ensuring that analytics events are captured even if the full analytics library isn't yet loaded. It also attempts to mark a performance entry for "wpm:start". ```JavaScript (function e(e,d,r,n,o,i){if(void 0===i&&(i={}),!Boolean(null===(t=null===(a=window.Shopify)||void 0===a?void 0:a.analytics)||void 0===t?void 0:t.replayQueue)){var a,t;window.Shopify=window.Shopify||{};var s=window.Shopify;s.analytics=s.analytics||{};var l=s.analytics;l.replayQueue=[],l.publish=function(e,d,r){return l.replayQueue.push([e,d,r]),!0};try{self.performance.mark("wpm:start")}catch(e){}}()); ``` -------------------------------- ### JavaScript Shopify Abandonment Tracking with sendBeacon Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This function tracks user abandonment events on a Shopify store by sending a beacon request to a Monorail endpoint when a user navigates away from the page. It leverages the `sendBeacon` API for reliable data transmission and the Performance API to calculate session duration. The payload includes shop ID, URL, navigation start time, duration, session token, and page type. ```JavaScript window.miYo2v4moj_shop_domain = 'www.dfxparts.com.au'; (function(){ if ("sendBeacon" in navigator && "performance" in window) { var session_token = document.cookie.match(/_shopify_s=([^;]*)/); function handle_abandonment_event(e) { var entries = performance.getEntries().filter(function(entry) { return /monorail-edge.shopifysvc.com/.test(entry.name); }); if (!window.abandonment_tracked && entries.length === 0) { window.abandonment_tracked = true; var currentMs = Date.now(); var navigation_start = performance.timing.navigationStart; var payload = { shop_id: 45696090275, url: window.location.href, navigation_start, duration: currentMs - navigation_start, session_token: session_token && session_token.length === 2 ? session_token[1] : "", page_type: "page" }; window.navigator.sendBeacon("https://monorail-edge.shopifysvc.com/v1/produce", JSON.stringify({ schema_id: "online_store_buyer_site_abandonment/1.1", payload: payload, metadata: { event_created_at_ms: currentMs, event_sent_at_ms: currentMs } })); } } window.addEventListener('pagehide', handle_abandonment_event); } }()); ``` -------------------------------- ### JavaScript: Initialize Shopify Trekkie Analytics Library Source: https://www.dfxparts.com.au/collections/fork-upgrade-kits/products/beta-x-trainer-fork-upgrade-kit-250-300 This snippet initializes the 'trekkie' (Shopify Analytics) library, making it available globally as window.ShopifyAnalytics.lib and window.trekkie. It defines an array of core methods ('identify', 'page', 'ready', 'track', 'trackForm', 'trackLink') and uses a factory pattern to create corresponding functions that push arguments onto the 'trekkie' array, enabling asynchronous tracking calls. ```JavaScript var trekkie = window.ShopifyAnalytics.lib = window.trekkie = window.trekkie || []; if (trekkie.integrations) { return; } trekkie.methods = [ 'identify', 'page', 'ready', 'track', 'trackForm', 'trackLink' ]; trekkie.factory = function(method) { return function() { var args = Array.prototype.slice.call(arguments); args.unshift(method); trekkie.push(args); return trekkie; }; }; for (var i = 0; i < trekkie.methods.length; i++) { var key = trekkie.methods[i]; trekkie[key] = trekkie.factory(key); } ``` -------------------------------- ### Manage Conversion Tracking Cookies in JavaScript Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides These functions handle the setting and checking of conversion tracking cookies. 'hasLoggedConversion' verifies if a conversion token exists in cookies, while 'setCookieIfConversion' sets a cookie with a 2-month expiry upon successful conversion. ```javascript var hasLoggedConversion = function(token) { if (token) { return document.cookie.indexOf('loggedConversion=' + token) !== -1; } return false; } var setCookieIfConversion = function(token) { if (token) { var twoMonthsFromNow = new Date(Date.now()); twoMonthsFromNow.setMonth(twoMonthsFromNow.getMonth() + 2); document.cookie = 'loggedConversion=' + token + '; expires=' + twoMonthsFromNow; } } ``` -------------------------------- ### Configure Trekkie and Track Page Views on Ready Source: https://www.dfxparts.com.au/ This snippet loads the initial configuration for the Trekkie library, including shop and theme IDs. It then registers a `ready` callback that executes once Trekkie is fully loaded, enabling Google Analytics integration and tracking the initial page view, along with conversion logic. ```javascript trekkie.load( {"Trekkie":{"appName":"storefront","development":false,"defaultAttributes":{"shopId":45696090275,"isMerchantRequest":null,"themeId":132974936227,"themeCityHash":"16954266077640314686","contentLanguage":"en","currency":"AUD"},"isServerSideCookieWritingEnabled":true,"monorailRegion":"shop_domain"},"Session Attribution":{},"S2S":{"facebookCapiEnabled":true,"source":"trekkie-storefront-renderer","apiClientId":580111}} ); var loaded = false; trekkie.ready(function() { if (loaded) return; loaded = true; window.ShopifyAnalytics.lib = window.trekkie; var originalDocumentWrite = document.write; document.write = customDocumentWrite; try { window.ShopifyAnalytics.merchantGoogleAnalytics.call(this); } catch(error) {}; document.write = originalDocumentWrite; window.ShopifyAnalytics.lib.page(null,{"pageType":"home","shopifyEmitted":true}); var match = window.location.pathname.match(/checkouts\/(.+)\/(thank_you|post_purchase)/); var token = match? match[1]: undefined; if (!hasLoggedConversion(token)) { setCookieIfConversion(token); } }); var eventsListenerScript = document.createElement('script'); eventsListenerScript.async = true; eventsListenerScript.src = "//www.dfxparts.com.au/cdn/shopifycloud/shopify/assets/shop_events_listener-f55dd2979ec32029c7d9e0b45"; ``` -------------------------------- ### Configure Trekkie and Execute Ready Callback for Analytics in JavaScript Source: https://www.dfxparts.com.au/pages/terms-of-use This final section loads the initial configuration for the Trekkie library, including application details, shop ID, and currency. It then defines a `trekkie.ready` callback that executes once the library is fully loaded. This callback integrates with Google Analytics, tracks page views, and manages conversion logging by checking and setting cookies based on checkout tokens. ```JavaScript trekkie.load( {"Trekkie":{"appName":"storefront","development":false,"defaultAttributes":{"shopId":45696090275,"isMerchantRequest":null,"themeId":132974936227,"themeCityHash":"16954266077640314686","contentLanguage":"en","currency":"AUD"},"isServerSideCookieWritingEnabled":true,"monorailRegion":"shop_domain"},"Session Attribution":{},"S2S":{"facebookCapiEnabled":true,"source":"trekkie-storefront-renderer","apiClientId":580111}} );\nvar loaded = false;\ntrekkie.ready(function() {\n if (loaded) return;\n loaded = true;\n window.ShopifyAnalytics.lib = window.trekkie;\n var originalDocumentWrite = document.write;\n document.write = customDocumentWrite;\n try {\n window.ShopifyAnalytics.merchantGoogleAnalytics.call(this);\n } catch(error) {};\n document.write = originalDocumentWrite;\n window.ShopifyAnalytics.lib.page(null,{"pageType":"page","resourceType":"page","resourceId":92497445027,"shopifyEmitted":true});\n var match = window.location.pathname.match(/checkouts\\/(.+)\\/("thank_you"|"post_purchase")/)\n var token = match? match[1]: undefined;\n if (!hasLoggedConversion(token)) {\n setCookieIfConversion(token);\n }\n});\nvar eventsListenerScript = document.createElement('script');\neventsListenerScript.async = true;\neventsListenerScript.src = "//www.dfx"; ``` -------------------------------- ### Implement Custom Document Write for jQuery Appending in JavaScript Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This function overrides 'document.write' to append content using jQuery if available, ensuring compatibility with scripts that might use 'document.write' after the DOM is ready. It checks for both 'window.jQuery' and 'window.Checkout.$'. ```javascript var customDocumentWrite = function(content) { var jquery = null; if (window.jQuery) { jquery = window.jQuery; } else if (window.Checkout && window.Checkout.$) { jquery = window.Checkout.$; } if (jquery) { jquery('body').append(content); } }; ``` -------------------------------- ### JavaScript RestockRocket Initial Application Activation Source: https://www.dfxparts.com.au/collections This snippet contains the initial setup logic for the RestockRocket application. It calls the `createRestockRocketContainer` function to prepare the DOM and logs an activation message, indicating the successful start of the application's client-side execution. ```javascript createRestockRocketContainer() console.debug('STOQ - extension activated') ``` -------------------------------- ### Mark Shopify Content Header Performance Start Source: https://www.dfxparts.com.au/collections/shock-upgrade-kits This JavaScript snippet uses the `window.performance.mark` API to record a timestamp, indicating the start of the 'shopify.content_for_header' loading phase. This is typically used for performance monitoring and analysis within the browser. ```JavaScript window.performance && window.performance.mark && window.performance.mark('shopify.content_for_header.start'); ``` -------------------------------- ### Shopify Analytics Library Setup and Page Tracking Source: https://www.dfxparts.com.au/products/kawasaki-klr650-fork-upgrade-kit This code executes once the Trekkie library is ready, assigning it to `window.ShopifyAnalytics.lib`. It temporarily overrides `document.write` to call `merchantGoogleAnalytics` and then tracks a page view event, specifically for product pages, including resource type and ID. ```JavaScript var loaded = false; trekkie.ready(function() {\n if (loaded) return;\n loaded = true;\n window.ShopifyAnalytics.lib = window.trekkie;\n var originalDocumentWrite = document.write;\n document.write = customDocumentWrite;\n try {\n window.ShopifyAnalytics.merchantGoogleAnalytics.call(this);\n } catch(error) {};\n document.write = originalDocumentWrite;\n window.ShopifyAnalytics.lib.page(null,{"pageType":"product","resourceType":"product","resourceId":5533228892323,"shopifyEmitted":true}); ``` -------------------------------- ### Define Root CSS Variables for Shopify Theme Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This CSS snippet defines a primary color variable for the root element, which can be used throughout the Shopify theme for consistent styling. It sets --engoc-primary-color to a specific red hexadecimal value. ```CSS :root { --engoc-primary-color: #cd2027; } ``` -------------------------------- ### JavaScript Polyfill for NodeList.prototype.forEach in IE9+ Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This snippet provides a polyfill to enable the `forEach` method on `NodeList` objects for Internet Explorer 9 and later versions. It checks if `NodeList.prototype.forEach` already exists and, if not, assigns `Array.prototype.forEach` to it. This ensures consistent iteration behavior across different browsers. ```JavaScript if (window.NodeList && !NodeList.prototype.forEach) { NodeList.prototype.forEach = Array.prototype.forEach; } ``` -------------------------------- ### Configure and Execute Trekkie Ready Callback Source: https://www.dfxparts.com.au/pages/shipping-and-returns This snippet configures the Trekkie library with storefront-specific attributes and then defines a `trekkie.ready` callback. This callback ensures that analytics operations, including page view tracking and conversion logging, are performed only once the Trekkie library is fully loaded and ready. ```JavaScript trekkie.load( {"Trekkie":{"appName":"storefront","development":false,"defaultAttributes":{"shopId":45696090275,"isMerchantRequest":null,"themeId":132974936227,"themeCityHash":"16954266077640314686","contentLanguage":"en","currency":"AUD"},"isServerSideCookieWritingEnabled":true,"monorailRegion":"shop_domain"},"Session Attribution":{},"S2S":{"facebookCapiEnabled":true,"source":"trekkie-storefront-renderer","apiClientId":580111}} ); var loaded = false; trekkie.ready(function() { if (loaded) return; loaded = true; window.ShopifyAnalytics.lib = window.trekkie; var originalDocumentWrite = document.write; document.write = customDocumentWrite; try { window.ShopifyAnalytics.merchantGoogleAnalytics.call(this); } catch(error) {}; document.write = originalDocumentWrite; window.ShopifyAnalytics.lib.page(null,{"pageType":"page","resourceType":"page","resourceId":92586541219,"shopifyEmitted":true}); var match = window.location.pathname.match(/checkouts\/(.+)\/(thank_you|post_purchase)/); var token = match? match[1]: undefined; if (!hasLoggedConversion(token)) { setCookieIfConversion(token); } }); ``` -------------------------------- ### Hide Popup on Overlay, Continue Shopping, or Close Click Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This jQuery snippet attaches a click event listener to the document. When an element with classes '.overlay', '.continue-shopping', or '.close-window' is clicked, it hides any element with the class '.engo-popup'. This is commonly used to close modal popups or notification windows. ```JavaScript $(document).on('click','.overlay, .continue-shopping, .close-window', function() { $(".engo-popup").hide(); }); ``` -------------------------------- ### Initialize Google Tag Manager (GTM) Data Layer Source: https://www.dfxparts.com.au/collections/fork-upgrade-kits/products/beta-x-trainer-fork-upgrade-kit-250-300 This standard Google Tag Manager snippet initializes the GTM data layer and asynchronously loads the GTM script. It pushes the `gtm.start` event with the current timestamp, ensuring that GTM starts tracking page activity as early as possible. The `GTM-MBV6PHN` ID specifies the container to load. ```javascript (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-MBV6PHN'); ``` -------------------------------- ### JavaScript Shopify Analytics Replay Queue Initialization Source: https://www.dfxparts.com.au/products/ktm890-adventure This script initializes the `Shopify.analytics` object, creating a `replayQueue` array and a `publish` function. The `publish` function pushes analytics events into the `replayQueue`, ensuring that events are captured even if the main Shopify analytics script has not fully loaded or processed them yet. It also attempts to mark a performance entry for 'wpm:start'. ```JavaScript (function e(e,d,r,n,o,i){if(void 0===i&&(i={}),!Boolean(null===(t=null===(a=window.Shopify)||void 0===a?void 0:a.analytics)||void 0===t?void 0:t.replayQueue)){var a,t;window.Shopify=window.Shopify||{};var s=window.Shopify;s.analytics=s.analytics||{};var l=s.analytics; l.replayQueue=[],l.publish=function(e,d,r){return l.replayQueue.push([e,d,r]),!0}; try{self.performance.mark("wpm:start")}catch(e){} ``` -------------------------------- ### Style Floating Button Containers with CSS Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides These CSS rules define the positioning and transformation for floating button containers, placing them on the right or left side of the viewport. They use fixed positioning and CSS transforms to rotate the containers for a unique visual effect. The `z-index` ensures they appear above other content. ```CSS right{ position:fixed; z-index:123123; top:calc(50% - 200px); right:0; transform:rotate(270deg); transform-origin:bottom right } .restock-rocket-button-container-float-left{ position:fixed; z-index:123123; top:calc(50% - 200px); left:40px; transform:rotate(90deg); transform-origin:top left } ``` -------------------------------- ### Style Preorder Description and Details with CSS Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This CSS defines the visual presentation for preorder descriptions and their associated details. The `.restock-rocket-preorder-description` adds padding and top margin, while `.preorder-description-details` indents the content with left padding and removes bottom margin. These styles ensure readability and proper spacing for preorder information. ```CSS .restock-rocket-preorder-description{ padding:10px 15px; margin-top:20px } .preorder-description-details{ padding-left:20px; margin-bottom:0 } ``` -------------------------------- ### JavaScript Shopify Analytics Replay Queue Setup Source: https://www.dfxparts.com.au/products/kawasaki-klr650-fork-upgrade-kit This code initializes the Shopify analytics replay queue, ensuring that analytics events can be buffered and processed. It checks if `window.Shopify.analytics.replayQueue` already exists, creating it and a `publish` method if not. The `publish` method pushes new events into the queue for later processing. ```javascript (function e(e,d,r,n,o,i){if(void 0===i&&(i={}),!Boolean(null===(t=null===(a=window.Shopify)||void 0===a?void 0:a.analytics)||void 0===t?void 0:t.replayQueue)){var a,t;window.Shopify=window.Shopify||{};var s=window.Shopify;s.analytics=s.analytics||{};var l=s.analytics;l.replayQueue=[],l.publish=function(e,d,r){return l.replayQueue.push([e,d,r]),!0};try{self.performance.mark("wpm:start")}catch(e){}}) ``` -------------------------------- ### Style Collection Buttons with CSS Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This CSS snippet styles buttons specifically for collections, setting their position, font size, line height, and padding. It ensures the button's height adjusts automatically and positions it relative to its parent. The `z-index` helps manage layering within the collection layout. ```CSS .restock-rocket-button-collection{ position:relative; font-size:13px; line-height:1; padding:7px; height:auto; z-index:3 } ``` -------------------------------- ### Initialize Shopify Trekkie Analytics Library Source: https://www.dfxparts.com.au/products/ktm890-adventure This snippet sets up the core Shopify Trekkie analytics library, defining its available methods ('identify', 'page', 'ready', 'track', 'trackForm', 'trackLink') and a factory function to create method wrappers. It also includes the `load` function responsible for dynamically injecting the Trekkie script into the DOM, ensuring analytics tracking is enabled. ```JavaScript var trekkie = window.ShopifyAnalytics.lib = window.trekkie = window.trekkie || []; if (trekkie.integrations) { return; } trekkie.methods = [ 'identify', 'page', 'ready', 'track', 'trackForm', 'trackLink' ]; trekkie.factory = function(method) { return function() { var args = Array.prototype.slice.call(arguments); args.unshift(method); trekkie.push(args); return trekkie; }; }; for (var i = 0; i < trekkie.methods.length; i++) { var key = trekkie.methods[i]; trekkie[key] = trekkie.factory(key); } trekkie.load = function(config) { trekkie.config = config || {}; trekkie.config.initialDocumentCookie = document.cookie; var first = document.getElementsByTagName('script')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.onerror = function(e) { var scriptFallback = document.createElement('script'); scriptFallback.type = 'text/javascript'; scriptFallback.onerror = function(error) { var Monorail = { produce: function produce(monorailDomain, schemaId, payload) { var currentMs = new Date().getTime(); var event = { schema_id: schemaId, payload: payload, metadata: { event_created_at_ms: currentMs, event_sent_at_ms: currentMs } }; return Monorail.sendRequest("https://" + monorailDomain + "/v1/produce", JSON.stringify(event)); }, sendRequest: function sendRequest(endpointUrl, payload) { if (window && window.navigator && typeof window.navigator.sendBeacon === 'function' && typeof window.Blob === 'function' && !Monorail.isIos12()) { var blobData = new window.Blob([payload], { type: 'text/plain' }); if (window.navigator.sendBeacon(endpointUrl, blobData)) { return true; } } var xhr = new XMLHttpRequest(); try { xhr.open('POST', endpointUrl); xhr.setRequestHeader('Content-Type', 'text/plain'); xhr.send(payload); } catch (e) { console.log(e); } return false; }, isIos12: function isIos12() { return window.navigator.userAgent.lastIndexOf('iPhone; CPU iPhone OS 12_') !== -1 || window.navigator.userAgent.lastIndexOf('iPad; CPU OS 12_') !== -1; } }; Monorail.produce('monorail-edge.shopifysvc.com', 'trekkie_storefront_load_errors/1.1', {shop_id: 45696090275, theme_id: 132974936227, app_name: "storefront", context_url: window.location.href, source_url: "//www.dfxparts.com.au/cdn/s/trekkie.storefront.7f48c99429cb25be36839f7a7bcca2ac8a69827d.min.js"}); }; scriptFallback.async = true; scriptFallback.src = '//www.dfxparts.com.au/cdn/s/trekkie.storefront.7f48c99429cb25be36839f7a7bcca2ac8a69827d.min.js'; first.parentNode.insertBefore(scriptFallback, first); }; script.async = true; script.src = '//www.dfxparts.com.au/cdn/s/trekkie.storefront.7f48c99429cb25be36839f7a7bcca2ac8a69827d.min.js'; first.parentNode.insertBefore(script, first); }; ``` -------------------------------- ### Apply Hover Effects to Restock Rocket Buttons with CSS Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This CSS snippet applies a consistent hover effect across various Restock Rocket buttons and containers. When hovered, the opacity of the elements is reduced to 0.8, providing visual feedback to the user. This simple transition enhances the interactivity of the UI. ```CSS .restock-rocket-button-container-float-left:hover, .restock-rocket-button-container-float-right:hover, .restock-rocket-button-container:hover, .restock-rocket-button-float:hover, .restock-rocket-button:hover{ opacity:.8 } ``` -------------------------------- ### Execute Trekkie Ready Callback for Page Tracking and Conversions Source: https://www.dfxparts.com.au/pages/contact-us This callback executes once the Trekkie library is fully loaded and ready for use. It ensures the library is properly assigned, temporarily overrides `document.write` for compatibility with Google Analytics, tracks the current page view, and logs conversions based on URL parameters and cookie checks. ```javascript var loaded = false; trekkie.ready(function() { if (loaded) return; loaded = true; window.ShopifyAnalytics.lib = window.trekkie; var originalDocumentWrite = document.write; document.write = customDocumentWrite; try { window.ShopifyAnalytics.merchantGoogleAnalytics.call(this); } catch(error) {}; document.write = originalDocumentWrite; window.ShopifyAnalytics.lib.page(null,{"pageType":"page","resourceType":"page","resourceId":92497477795,"shopifyEmitted":true}); var match = window.location.pathname.match(/checkouts\/(.+)\/(thank_you|post_purchase)/) var token = match? match[1]: undefined; if (!hasLoggedConversion(token)) { setCookieIfConversion(token); } }); ``` -------------------------------- ### Execute JavaScript After ajaxCart Loads in DOM Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This code binds a function to the 'ajaxCart.afterCartLoad' event on the 'body' element. The callback function executes once the cart content has been successfully loaded and rendered in the DOM by the 'ajaxCart' utility. It provides a hook for post-load operations, such as opening a cart drawer or updating UI elements. ```JavaScript jQuery('body').on('ajaxCart.afterCartLoad', function(evt, cart) { // Bind to 'ajaxCart.afterCartLoad' to run any javascript after the cart has loaded in the DOM /* timber.RightDrawer.open(); */ }); ``` -------------------------------- ### Configure and Initialize jQuery ajaxCart for Shopify Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This snippet defines the configuration for an 'ajaxCart' utility, specifying selectors for cart elements and money format. It then initializes the 'ajaxCart' plugin on document ready, enabling dynamic cart updates without page reloads. This requires the 'ajaxCart' JavaScript library to be loaded. ```JavaScript var ajaxCartConfig = { cartContainer: '.enj-minicart-ajax', addToCartSelector: '.enj-add-to-cart-btn', cartCountSelector: '.enj-cartcount', cartCostSelector: '.enj-cartcost', moneyFormat: "${{amount}} AUD" }; jQuery(function($) { ajaxCart.init(ajaxCartConfig); }); ``` -------------------------------- ### Mark Shopify Header Content Load Start Source: https://www.dfxparts.com.au/pages/shipping-and-returns Uses the `window.performance.mark` API to record a timestamp for the beginning of the Shopify content for header loading. This is useful for performance monitoring and debugging. ```JavaScript window.performance && window.performance.mark && window.performance.mark('shopify.content_for_header.start'); ``` -------------------------------- ### HTML: Implement General Quantity Adjustment Buttons Source: https://www.dfxparts.com.au/pages/crf300-fork-and-shock-upgrade-install-guides This HTML snippet provides a generic set of buttons and an input field for adjusting quantities. It's designed for general use cases where quantity needs to be modified, such as on product pages or in a standard cart view, offering flexible quantity control. ```HTML