Comments (4)
we had to disable it. analytics data is priority over performance for our business now. ios users are about 1/3 and it's a lot of data lost.
we'll monitor this thread.
just one of many apple things we had to deal with. safari seems to be the new internet explorer for web evolution. :/
from partytown.
Ok not sure if this is exactly the same issue, but we found a drop in traffic as well when using Google Tag Manger, and I think we share the same underlying problem. Specifically for us, the drop was from Safari (in-app) traffic, and we were able to fix it by updating the GTM snippet.
I'll explain what the issue is below but the TL;DR is, because the GTM snippet dynamically loads the gtm.js script, if the snippet itself is loaded by partytown, then the fallback partytown has in place won't work. You need to check to make sure serviceWorkers are supported. Here's our updated snippet that started working for us. We added navigator
as an argument to check if service workers were available.
(function(w,d,s,l,i,n){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;
j.type=n.serviceWorker ? 'text/partytown' : ''; // <--------------make sure service workers work. if not, load like normal.
j.async=!n.serviceWorker; // <------------------- this isn't necessary, but the script is already a little delayed from partytown. Didn't want it delayed any more than it is.
f.parentNode.insertBefore(j,f);
w.dispatchEvent(new CustomEvent('ptupdate')); // <----------------- because it's dynamically loaded, make sure partytown knows about it.
})(window,document,'script','dataLayer','{{ containerId }}', navigator);
The reason is because there are two different webviews apps can use, SFSafariViewController and WKWebView. Apps like slack use SFSafariViewController which is essentially full featured safari and includes support for service workers. Apps like Instagram appear to use WKWebView which is basically a barebones Safari, and doesn't appear to support service workers.
I'm not super familiar with next.js, but it looks like your loading the GTM script as a web worker from the get-go. If there's no fallback logic to load your GTM snippet on the main thread, then it won't load on apps like Instagram.
Partytown itself tries to fallback to loading any text/partytown
scripts on the main thread when serviceWorkers are disabled. However with the GTM snippet, and from a lot of examples i've seen on the internet, simply adding j.type=text/partytown
in the GTM snippet won't fallback correctly. Reason is because partytown will fallback the snippet itself, but that snippet is dynamically loading scripts itself which partytown doesn't seem to account for.
I think the docs for for GTM in partytown need to be updated as well. Gtag and GTM are two different things. The current HTML
example shows how to load the gtag snippet, which is different than the tag manager snippet i'm referencing here.
from partytown.
is it related to this one #546?
from partytown.
I don't believe it's related to that bug. We had the same issue, which resulted in lost conversions. We have our library in /~partytown
, and it generated 404 errors to /~partytownproxytown and to /~partytown/proxytown, but only on Apple devices - iOS Safari 604.1, iPad Safari 604.1, and MacOS Safari 605.1.15. We are using PartyTown 0.8.2, though for awhile we were referencing a different directory which has 0.8.1, with the same errors. We have a Cloudflare worker as a proxy.
Config:
window.onload = function () {
window.partytown = {
resolveUrl: function(url, location, type) {
if (type === 'script') {
let proxyUrl = new URL("https://www.ourdomain.com/api/partytown/proxy")
proxyUrl.searchParams.append('url', url.href)
return proxyUrl;
}
return new URL(url);
},
// debug: true,
lib: "/~partytown/",
forward: [
'dataLayer.push', // Google Tag Manager
'fbq', // Facebook
'_tfa.push', // Taboola
],
}
document.head.appendChild(partytownScript);
}
from partytown.
Related Issues (20)
- [🐞]partytown throws error in chrome developer console and not able to connect to GTM preview mode HOT 13
- [🐞]404 errror throws while implementing partytown in gatsby application HOT 3
- Failed to register a ServiceWorker for scope ('https://example/~partytown/') with script ('https://example.com/~partytown/partytown-sw.js'): The script resource is behind a redirect, which is disallowed. HOT 1
- Partytown integration with Astro makes over 10'000 proxytown requests on page load[🐞] HOT 2
- [🐞] Google Tag Manager NextJS forward events coming as blank [] HOT 1
- [🐞] Cannot read property 'Error' of null
- [🐞] Proxy object could not be cloned HOT 1
- [🐞] Firefox: 404 partytown-sandbox-sw.html HOT 3
- [🐞] Firefox: Private Browsing for external Scripts HOT 1
- [🐞] GA4 sessions plummeted after migration of GTM to Partytown HOT 13
- [🐞] Objects and object properties can't be forwarded HOT 2
- [🐞]in statement is not reliable when running through partytown
- [📖] resolveSendBeaconRequestParameters missing in docs and React types HOT 1
- [🐞]: forwarding gtm dataLayer.push breaks immediate dataLayer pushes HOT 3
- [🐞] page_view and on_load events are not firing in GA4
- [🐞] Intercom does not work with party town HOT 2
- [🐞]user_engagement is not working in GA4
- [🐞] AppsFlyer Smart Banner does not work
- [🐞] How to setup correctly partytown for astro.js HOT 1
- [🐞] GTM doesnt work HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from partytown.