Skip to content

Remote Code

WXT will automatically download and bundle imports with the url: prefix so the extension does not depend on remote code, a requirement from Google for MV3.

Google Analytics

For example, you can import Google Analytics:

// utils/google-analytics.ts
import 'url:';

window.dataLayer = window.dataLayer || [];
// NOTE: This line is different from Google's documentation
window.gtag = function () {
gtag('js', new Date());
gtag('config', 'G-XXXXXX');

Then you can import this in your HTML files to enable Google Analytics:

// popup/main.ts
import '~/utils/google-analytics';

gtag('event', 'event_name', {
  key: 'value',