tracking-propensity.ts 579 B

1234567891011121314151617181920212223
  1. import getMeta from '@/utils/meta'
  2. import {
  3. createTrackingLoader,
  4. insertScript,
  5. } from '@/infrastructure/tracking-loader'
  6. const { propensityId } = getMeta('ol-ExposedSettings')
  7. const loadPropensityScript = (id: string) => {
  8. insertScript({
  9. src: 'https://cdn.propensity.com/propensity/propensity_analytics.js',
  10. crossorigin: 'anonymous',
  11. onload: () => {
  12. if (typeof window.propensity !== 'undefined') {
  13. window.propensity(id)
  14. }
  15. },
  16. })
  17. }
  18. if (propensityId) {
  19. createTrackingLoader(() => loadPropensityScript(propensityId), 'Propensity')
  20. }