|
| 1 | +var trackEvents = { |
| 2 | + recordClick: function(eventCategory, eventLabel) { |
| 3 | + if (typeof ga == "function") { |
| 4 | + ga('send', 'event', { |
| 5 | + eventCategory: eventCategory, |
| 6 | + eventAction: "click", |
| 7 | + eventLabel: eventLabel |
| 8 | + }); |
| 9 | + } |
| 10 | + |
| 11 | + if (typeof fbq === "function") { |
| 12 | + fbq("trackCustom", eventCategory, { |
| 13 | + target: eventLabel |
| 14 | + }); |
| 15 | + } |
| 16 | + }, |
| 17 | + |
| 18 | + bind: function() { |
| 19 | + // Clicks on the main menu |
| 20 | + $(".main-menu ul li a").on("click", function() { |
| 21 | + trackEvents.recordClick("Global Nav", $(this).text()); |
| 22 | + return true; |
| 23 | + }); |
| 24 | + |
| 25 | + // Clicks on Resource cards |
| 26 | + $(".resource-card a").on("click", function() { |
| 27 | + trackEvents.recordClick("Resource Card", $(this).find("h4").text()); |
| 28 | + return true; |
| 29 | + }); |
| 30 | + |
| 31 | + // Clicks on Ecosystem Project cards |
| 32 | + $(".ecosystem-card a").on("click", function() { |
| 33 | + trackEvents.recordClick("Ecosystem Project Card", $(this).find("h4").text()); |
| 34 | + return true; |
| 35 | + }); |
| 36 | + |
| 37 | + // Clicks on 'Get Started' call to action buttons |
| 38 | + $("[data-cta='get-started']").on("click", function() { |
| 39 | + trackEvents.recordClick("Get Started CTA", $(this).text()); |
| 40 | + return true; |
| 41 | + }); |
| 42 | + |
| 43 | + // Clicks on Cloud Platforms in Quick Start Module |
| 44 | + $(".cloud-option").on("click", function() { |
| 45 | + var platformName = $.trim($(this).find(".cloud-option-body").text()); |
| 46 | + trackEvents.recordClick("Quick Start Module - Cloud Platforms", platformName); |
| 47 | + }); |
| 48 | + |
| 49 | + // Clicks on Cloud Platform Services in Quick Start Module |
| 50 | + $(".cloud-option ul li a").on("click", function() { |
| 51 | + var platformName = $.trim( |
| 52 | + $(this). |
| 53 | + closest("[data-toggle='cloud-dropdown']"). |
| 54 | + find(".cloud-option-body"). |
| 55 | + text() |
| 56 | + ); |
| 57 | + |
| 58 | + var serviceName = $.trim($(this).text()); |
| 59 | + |
| 60 | + trackEvents.recordClick( |
| 61 | + "Quick Start Module - Cloud Platforms", |
| 62 | + platformName + " - " + serviceName |
| 63 | + ); |
| 64 | + |
| 65 | + return true; |
| 66 | + }); |
| 67 | + |
| 68 | + // Clicks on options in Quick Start - Locally |
| 69 | + $(".quick-start-module .row .option").on("click", function() { |
| 70 | + var selectedOption = $.trim($(this).text()); |
| 71 | + var rowIndex = $(this).closest(".row").index(); |
| 72 | + var selectedCategory = $(".quick-start-module .headings .title-block"). |
| 73 | + eq(rowIndex). |
| 74 | + find(".option-text"). |
| 75 | + text(); |
| 76 | + |
| 77 | + trackEvents.recordClick( |
| 78 | + "Quick Start Module - Local Install", |
| 79 | + selectedCategory + ": " + selectedOption |
| 80 | + ) |
| 81 | + }) |
| 82 | + } |
| 83 | +}; |
0 commit comments