Changeset 3143555
- Timestamp:
- 08/29/2024 10:54:24 AM (19 months ago)
- Location:
- setmore-appointments/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (1 diff)
-
script/setmoreFormScript.js (modified) (2 diffs)
-
setmore.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
setmore-appointments/trunk/readme.txt
r3072242 r3143555 1 1 === Plugin Name === 2 2 3 Contributors: Anitha/Rajesh 3 Contributors: Anitha/Rajesh/Sankavi 4 4 Tags: Free, appointments, appointment, scheduling, software, booking, calendar, agenda, management, online, diary, widget, Setmore 5 5 Requires at least: 3.7.2 6 Tested up to: 6. 5.27 Stable tag: 12. 16 Tested up to: 6.6.1 7 Stable tag: 12.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
setmore-appointments/trunk/script/setmoreFormScript.js
r2721397 r3143555 66 66 }) 67 67 }) 68 69 async function sendAnalytics(bookingpage, event) { 70 const currentTimestampMicros = Date.now() * 1000; 71 const companyKey = bookingpage.split('/').pop(); 72 const measurementId = `G-QGCR29L2YV`; 73 const apiSecret = `c8RPSMB0SSyNd8XfOonPBg`; 74 const userType = event.target.id === "signup" ? "new_customer" : "customer"; 75 try { 76 const response = await fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`, { 77 method: "POST", 78 body: JSON.stringify({ 79 "client_id": companyKey, 80 "timestamp_micros": currentTimestampMicros, 81 "non_personalized_ads": false, 82 "events": [ 83 { 84 "name": "wordpress_plugin_successful_connection", 85 "params": { 86 "company_id": companyKey, 87 "User_type": userType, 88 "Brand": "Setmore" 89 } 90 } 91 ] 92 }) 93 }); 94 95 if (response.status === 204) { 96 console.log("Analytics data sent successfully"); 97 } else { 98 console.error("Unexpected response:", response.status, response.statusText); 99 } 100 } catch (error) { 101 console.error("Error sending analytics data:", error); 102 } 103 } 104 68 105 function saveBookingPageConfiguration(setmoreBookingPageURl,languageOption,version){ 69 106 if(setmoreBookingPageURl){ … … 109 146 document.querySelector("#connectBlock").style.display = "none"; 110 147 saveBookingPageConfiguration(urlParams.get("bookingpageurl"),"English",urlParams.get("version")); 148 sendAnalytics(urlParams.get("bookingpageurl"), event); 111 149 window.clearInterval(pollTimer); 112 150 popupWindow.close(); -
setmore-appointments/trunk/setmore.php
r3072242 r3143555 20 20 { 21 21 /* Deletes the database field */ 22 $booking_page_url = get_option('setmore_booking_page_url'); 23 24 // Send the deactivation event to Google Analytics with the booking page URL 25 send_user_analytics($booking_page_url); 22 26 delete_option('setmore_booking_page_url'); 23 27 delete_option('languageOption'); 24 28 delete_option('setmore_booking_page_version'); 29 } 30 31 function send_user_analytics($booking_page_url) 32 { 33 if ($booking_page_url) { 34 $parsed_url = parse_url($booking_page_url, PHP_URL_PATH); 35 $segments = explode('/', rtrim($parsed_url, '/')); 36 $companyKey = array_pop($segments); 37 38 $url = 'https://www.google-analytics.com/mp/collect?api_secret=c8RPSMB0SSyNd8XfOonPBg&measurement_id=G-QGCR29L2YV'; 39 $body = array( 40 'client_id' => $companyKey, 41 'timestamp_micros' => round(microtime(true) * 1000000), 42 'non_personalized_ads' => false, 43 'events' => array( 44 array( 45 'name' => 'wordpress_plugin_deactivated', 46 'params' => array( 47 'Company' => $companyKey, 48 'Brand' => 'Setmore', 49 ), 50 ), 51 ), 52 ); 53 54 $args = array( 55 'method' => 'POST', 56 'headers' => array('Content-Type' => 'application/json'), 57 'body' => json_encode($body), 58 ); 59 60 $request = wp_remote_post($url, $args); 61 62 if (is_wp_error($request) || wp_remote_retrieve_response_code($request) != 204) { 63 error_log(print_r($request, true)); 64 } 65 66 } 25 67 } 26 68
Note: See TracChangeset
for help on using the changeset viewer.