1// Create us if we don't exist 2// ----------------------------------------------------- 3if (!(ecommerceUtils)) { 4 var ecommerceUtils = {}; 5} 6 7// Self-Invoke, using closure and namespacing 8// ----------------------------------------------------- 9(function () { 10 // Create a short hand ref to ourself (private scope) 11 //------------------------------------------------ 12 var self = ecommerceUtils; 13 14 // ----------------------------------------------------- 15 // -- PUBLIC FUNCTIONS --------------------------------- 16 // ----------------------------------------------------- 17 18 // Push the User Login action to the DataLayer 19 self.pushUserLogin = function (action, id, email, role, v = 3) { 20 (window.dataLayer = window.dataLayer || []).push({ 21 'event': 'page.user', 22 'page.user': { 23 'v': v, 24 'id': id, // The system user ID of the logged-in user. 25 'role': role, // The system role of the logged-in user. 26 'emails': [email], // Array of strings; the email addresses associated with the logged-in user. 27 'stateChange': { // Only need to include this object when user logs in or out. 28 'platform': "Sunbelt Rentals", // The system used to log user in (e.g. "Wordpress", "Facebook", etc). 29 'action': action // "login" when user logs in (via login form, SSO, OAuth, or any other means) 30 // "logout" when user actively logs out (such as by clicking a 'Logout' button) 31 // "auto-logout-expired" when user is logged out due to the session expiring 32 // "auto-logout-other" when user is automatically logged out for other reason 33 } 34 } 35 }); 36 }; 37 38 // Push the User Login action to the DataLayer 39 self.pushUserLoginAction = function (action) { 40 var role = (sbSiteUserData.Profile.IsSiteAdmin() || sbSiteUserData.Profile.IsWebAdmin()) ? "Admin" : "User"; 41 42 self.pushUserLogin(action, sbSiteUserData.Profile.ID(), sbSiteUserData.Profile.Email(), role) 43 }; 44 45 // Push ECommerce config to the DataLayer 46 self.pushConfig = function () { 47 var currency = ""; 48 var companyID = sbSiteUserData.CurrentPC.CompanyID(); 49 50 if (companyID != 0){ 51 currency = companyID == 1 ? "USD" : "CAD"; 52 } 53 54 (window.dataLayer = window.dataLayer || []).push({ 55 'event': 'page.eec._config', 56 'page.eec._config': { 57 'v': 2, // <-- DO NOT EDIT. 58 'currencyCode': currency// The unit used for all price values, as a ISO 4217 currency code. 59 } 60 }); 61 } 62}());
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.