| 1 |
// Load Amplitude SDK |
| 2 |
const script = document.createElement('script'); |
| 3 |
script.src = 'https://cdn.eu.amplitude.com/script/3573fa11b8c5b4bcf577ec4c8e9d5cb6.js'; |
| 4 |
script.async = true; |
| 5 |
script.onload = function () { |
| 6 |
window.amplitude.init('3573fa11b8c5b4bcf577ec4c8e9d5cb6', { |
| 7 |
serverZone: 'EU', |
| 8 |
fetchRemoteConfig: true, |
| 9 |
defaultTracking: false |
| 10 |
}); |
| 11 |
}; |
| 12 |
document.head.appendChild(script); |
| 13 |
|
| 14 |
// Global tracking function |
| 15 |
window.trackAmplitudeEvent = function (eventName, additionalProperties = {}) { |
| 16 |
try { |
| 17 |
if (window.amplitude?.track) { |
| 18 |
const properties = { |
| 19 |
source: 'wordpress_plugin', |
| 20 |
timestamp: new Date().toISOString(), |
| 21 |
...additionalProperties |
| 22 |
}; |
| 23 |
|
| 24 |
window.amplitude.track(eventName, properties); |
| 25 |
} else { |
| 26 |
} |
| 27 |
} catch (error) { |
| 28 |
} |
| 29 |
} |
| 30 |
|