1 // Add Royal Pass if available 2 if (moengageUser.royalpass) { 3 Moengage.add_user_attribute("royal_pass", moengageUser.royalpass); 4 } 5 6 7// Moengage ID added in prime link 8jQuery(document).ready(function () { 9 // Function to get USER_ATTRIBUTE_UNIQUE_ID from localStorage's MOE_DATA.USER_DATA.attributes 10 function getMoengageId() { 11 try { 12 const moeData = JSON.parse(localStorage.getItem('MOE_DATA')); 13 if (moeData && moeData.USER_DATA && moeData.USER_DATA.attributes) { 14 const attributes = moeData.USER_DATA.attributes; 15 // Find the attribute with key "USER_ATTRIBUTE_UNIQUE_ID" 16 const uniqueIdAttr = attributes.find(attr => attr.key === "USER_ATTRIBUTE_UNIQUE_ID"); 17 return uniqueIdAttr ? uniqueIdAttr.value : null; 18 } 19 return null; 20 } catch (error) { 21 console.error('Error parsing MOE_DATA from localStorage:', error); 22 return null; 23 } 24 } 25 26 // Function to Base64 encode a string 27 function base64Encode(value) { 28 try { 29 return btoa(value); // Encode to Base64 30 } catch (error) { 31 console.error('Error encoding value to Base64:', error); 32 return null; 33 } 34 } 35 36 // Check if USER_ATTRIBUTE_UNIQUE_ID exists 37 const moengageId = getMoengageId(); 38 if (moengageId) { 39 const encodedId = base64Encode(moengageId); // Encode the ID to Base64 40 if (encodedId) { 41 // Add event listener to specific links 42 jQuery('a[href^="https://prepinsta.com/prime/"]').click(function (e) { 43 e.preventDefault(); // Prevent the default click action 44 45 const link = jQuery(this); 46 let url = new URL(link.attr('href')); 47 48 // Append Base64 encoded USER_ATTRIBUTE_UNIQUE_ID to the query parameters 49 url.searchParams.set('mu_id', encodedId); 50 51 // Open the updated URL in a new tab 52 window.open(url.toString(), '_blank'); 53 }); 54 } 55 } 56}); 57 58 59 60 61 62// Track a dynamic event 63document.addEventListener("DOMContentLoaded", function () { 64 const validIds = ["l1", "l2", "l3", "l4", "home", "syllabus"]; 65 66 67 let pageType = "Unknown"; // Default page type 68 let foundId = null; // To store the ID found on the page 69 70 // Loop through valid IDs and check if any exist on the page 71 for (const id of validIds) { 72 if (document.getElementById(id)) { 73 foundId = id; 74 break; 75 } 76 } 77 78 // Assign page type based on the found ID 79 if (foundId) { 80 pageType = foundId; // The page type is the ID itself 81 }else if (jQuery('.elementor').length > 0) { 82 pageType = "elementor"; 83 } 84 85 // Track page view when the page loads 86 Moengage.track_event("Page_Viewed", { 87 page_name: document.title, // Current page title 88 page_url: window.location.href, // Current page URL 89 user_id: moengageUser.id || "Guest", 90 user_email: moengageUser.email || "Not Available", 91 page_type: pageType, 92 }); 93 94 console.log("MoEngage Page View Tracked"); 95}); 96 97 98// Track Event for Quiz 99document.addEventListener("DOMContentLoaded", function () { 100 // Select the button element 101 const freeQuizButton = document.getElementById("free-quiz-btn"); 102 const paidQuizButton = document.getElementById("paid-quiz-btn"); 103 const subscribeClickButton = document.getElementById("Top-menu-subscribe"); 104 const getPrimeClickButton = document.getElementById("Top-menu-get-prime"); 105 const headerMenuClick = document.getElementById("menu-primary-menu-new-2020"); 106 107 if (freeQuizButton) { 108 // Add a click event listener 109 freeQuizButton.addEventListener("click", function () { 110 const quizName = this.getAttribute("data-quiz-name"); 111 112 // Track the event in MoEngage 113 Moengage.track_event("Free_Quiz_Clicked", { 114 quiz_name: quizName, 115 user_id: moengageUser.id || "Guest", 116 user_email: moengageUser.email || "Not Available", 117 page_name: document.title, 118 page_url: window.location.href, 119 }); 120 121 console.log("Free Quiz Click event tracked."); 122 }); 123 } 124 125 if (paidQuizButton) { 126 // Add a click event listener 127 paidQuizButton.addEventListener("click", function () { 128 const quizName = this.getAttribute("data-quiz-name"); 129 130 // Track the event in MoEngage 131 Moengage.track_event("Paid_Quiz_Clicked", { 132 quiz_name: quizName, 133 user_id: moengageUser.id || "Guest", 134 user_email: moengageUser.email || "Not Available", 135 page_name: document.title, 136 page_url: window.location.href, 137 }); 138 139 console.log("Paid Quiz Click event tracked."); 140 }); 141 } 142 143 if (subscribeClickButton) { 144 // Add a click event listener 145 subscribeClickButton.addEventListener("click", function () { 146 // Track the event in MoEngage 147 Moengage.track_event("Subscribed_button_Clicked", { 148 user_id: moengageUser.id || "Guest", 149 user_email: moengageUser.email || "Not Available", 150 page_name: document.title, 151 page_url: window.location.href, 152 }); 153 }); 154 } 155 156 if (getPrimeClickButton) { 157 // Add a click event listener 158 getPrimeClickButton.addEventListener("click", function () { 159 // Track the event in MoEngage 160 Moengage.track_event("Getprime_header_button", { 161 user_id: moengageUser.id || "Guest", 162 user_email: moengageUser.email || "Not Available", 163 page_name: document.title, 164 page_url: window.location.href, 165 }); 166 }); 167 } 168}); 169 170 171jQuery(document).ready(function () { 172 // Add click event listener to Header Menu 173 jQuery('#menu-primary-menu-new-2020 a').click(function () { 174 175 const linkTitle = jQuery(this).attr('title'); 176 177 // Track the event in MoEngage 178 Moengage.track_event("Header_menu_click", { 179 menu_title: linkTitle, 180 user_id: moengageUser.id || "Guest", 181 user_email: moengageUser.email || "Not Available", 182 page_name: document.title, 183 page_url: window.location.href, 184 }); 185 }); 186 187 188 // Add click event listener to Hero signup button 189 jQuery('#Home-page-hero-signup').click(function () { 190 // Track the event in MoEngage 191 Moengage.track_event("Homepage_heroSection_signup", { 192 user_id: moengageUser.id || "Guest", 193 user_email: moengageUser.email || "Not Available", 194 page_name: document.title, 195 page_url: window.location.href, 196 }); 197 }); 198 199 200 // Add click event listener to Prime main advertise 201 jQuery('#animation-container').click(function () { 202 // Track the event in MoEngage 203 Moengage.track_event("Prime_main_advertise", { 204 user_id: moengageUser.id || "Guest", 205 user_email: moengageUser.email || "Not Available", 206 page_name: document.title, 207 page_url: window.location.href, 208 }); 209 }); 210 211 // Add click event listener to run compiler 212 jQuery('.ls-try-it').click(function () { 213 // Track the event in MoEngage 214 Moengage.track_event("run_compiler", { 215 user_id: moengageUser.id || "Guest", 216 user_email: moengageUser.email || "Not Available", 217 page_name: document.title, 218 page_url: window.location.href, 219 }); 220 console.log('Run compiler event passed') 221 }); 222}); 223 224 225 226
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.