rtbhouse-apps / gtm-tag-template-hosted-js

GTM Tag template for hosted js
Apache License 2.0
2 stars 1 forks source link

Injected js script to use fetch API with keepalive: true #10

Open andrew-ignatiev opened 3 weeks ago

andrew-ignatiev commented 3 weeks ago

Hey guys,

We are not sure if this is the right repo to rise our issue, but we've not found a dedicated repo for js sdk which is being injected by this template 'https://tags.creativecdn.com/' + makeString(taggingHash) + '.js'. If this is not right repo could you please pass it to appropriate dev team / repo.

We see that js sdk uses fetch API to send tracking requests, but browsers may cancel some of them when customer navigate away from one domain to another. For example when Customer click on checkout button customer can be redirected from www.example.com to checkout.example.com and as a result the request with eventType: startorder will be canceled by browser.

There is an API navigator.sendBeacon which is designed to fix exactly such issue. The sendBeacon uses fetch API and there is statement in documentation:

The sendBeacon() method does not provide ability to customize the request method, provide custom request headers, or change other processing properties of the request and response. Applications that require non-default settings for such requests should use the [FETCH] API with keepalive set to true.

Could you please extend your fetch API options and include { keepalive: true } ?

dgrtbh commented 3 weeks ago

@andrew-ignatiev, we will review your request; thanks for getting in touch. I'll post in this thread as soon as I have an update