For GA3 analytics.js (Universal Analytics) we can disable protocol checking by ga('set', 'checkProtocolTask', null)
( https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks#disabling_a_task ) but how can we disable it for gtag.js and new GA4 properties G-xxxxxxxxx? In source code of https://www.google-analytics.com/analytics.js there is checkProtocolTask but in https://www.googletagmanager.com/gtag/js after beautification I do not see something similar and protocol checking is hardcoded "http:" != k && "https:" != k && (E(29), e.abort())
. With GA4 it is not possible to track webview on file:// protocol.
UPDATE: GA4 indeed doesn't currently provide support for tasks but it should be added to feature request ( https://issuetracker.google.com/issues/174954288 )