How to Add Google Analytics to Any Website Using Webfuse

June 16, 20256 min read

Want to see exactly how users interact with websites you don't own, like Amazon or a competitor's site? Webfuse makes this possible by letting you add your Google Analytics code to any site through a special link. This guide will walk you through the process step-by-step, so you can track user behavior easily.

For a real-world example, check out our demo site, which shows this setup tracking sites like Amazon and BestBuy.

Prerequisites: What You'll Need

Before starting, gather these:

  • A Webfuse account: Sign up or log in at webfuse.com.
  • A Google Analytics account: Set up a GA4 property and grab your Measurement ID (looks like G-XXXXXXXXXX).
  • A text editor: Any simple editor like Notepad or VS Code will do.

Step 1: Creating Your Google Analytics Injector Extension

First, we'll create a small extension that adds Google Analytics code to websites loaded via Webfuse.

Editor Showing The Extension Code
  1. On your computer, create a folder named ga-injector-extension.
  2. Inside the folder, make a file called manifest.json and paste this JSON:
{
  "manifest_version": 3,
  "name": "GA4 Injector",
  "version": "1.0",
  "description": "Injects GA4 tracking code into pages via Webfuse.",
  "content_scripts": [
    {
      "js": ["content.js"],
      "matches": ["<all_urls>"],
      "run_at": "document_start"
    }
  ],
  "host_permissions": ["<all_urls>"]
}
  1. In the same folder, make a file called content.js with the following content:
// Inject Google Analytics gtag.js into every page
(function injectGtag() {
    if (window.__GTAG_INJECTED__) return;
    window.__GTAG_INJECTED__ = true;
    // Inject the gtag.js script (async)
    var gtagScript = document.createElement('script');
    gtagScript.async = true;
    gtagScript.src = "https://www.googletagmanager.com/gtag/js?id=G-VFQFZKX16G";
    document.head.appendChild(gtagScript);

    // Inject the gtag config script
    var inlineScript = document.createElement('script');
    inlineScript.innerHTML = `window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', 'G-XXXXXXXXXX');`;
    document.head.appendChild(inlineScript);
})();
  1. Make sure to replace 'G-XXXXXXXXXX' with your GA4 Measurement ID from Google Analytics.

This script will dynamically add the necessary Google Analytics gtag.js library and configuration script to the page's . It's ready to be uploaded and installed into your Webfuse Space in the next step.

Step 2: Setting Up Your Webfuse Space and Installing the Extension

Now we will need to set up a Webfuse Space to use our new extension.

Navigate to webfuse.com/studio/ and sign in to your account. Select "Solo" to start creating a new space.

Make sure to use Google Chrome Browser which is currently the only supported browser for uploading extensions folders.

Webfuse Solo Space Creation Interface

Enter a descriptive name for your workspace (e.g., "Third-Party Analytics") and specify a custom URL slug. Click "Next" to continue.

Naming Webfuse Space

Keep the default settings and select "Open Space" to enter your newly created space.

Webfuse workspace dashboard showing newly created space ready for extension installation

Open the "Settings" panel and select "Extensions" to begin the installation process.

Webfuse settings panel with Extensions tab highlighted for managing browser extensions

Use Webfuse Default Storage to start managing extensions without additional storage configurations.

Webfuse default storage configuration screen for extension file management

After setting the storage, we can now proceed with uploading our extensions folder.

File upload interface in Webfuse for selecting and uploading the GA4 injector extension folder

Navigate to the location on your computer where you saved the ga-injector-extension and

select the entire folder.

Computer file explorer showing the ga-injector-extension folder selected for upload to Webfuse

Click "View files" to finalize uploading the extension files in Webfuse space:

Webfuse extension upload confirmation screen showing successfully uploaded manifest.json and content.js files

The extension has been successfully uploaded and is now active for all sessions in this space. Before testing it, one important setting needs to be adjusted. We'll need to enable setting the session start URL via a query parameter. Navigate to Space Settings to make this change.

Webfuse space settings navigation menu with Permissions tab access for URL parameter configuration

Select the "Permissions" tab and enable "Allow to open URL from query parameter". Make sure save your changes.

Webfuse permissions settings showing the enabled option to allow URL opening from query parameters

We can now close the settings panel.

Webfuse workspace interface with settings panel being closed after successful configuration

And terminate the current session.

Webfuse session termination screen preparing to test the newly installed Google Analytics extension

Our custom "GA4 Injector" extension is now installed and active within this specific Webfuse Space. Any website session initiated from this space will now automatically have this extension running and inject your Google Analytics tracking code onto every page loaded.

To track a website, you use a Webfuse link that loads the site with your extension active.

You can also check the demo site to see links like this in action for Amazon and BestBuy. When clicked:

  1. The link goes to Webfuse.
  2. Webfuse loads the site (e.g., Amazon) with our Analytics Demo extension.
  3. User activity is tracked and displayed in a demo overlay.

Verifying Data Collection in Google Analytics

Having browsed the target website through your configured Webfuse link, the final step is to confirm that this activity registered in your Google Analytics property.

Checking Realtime Reports:

The quickest way to check is usually the Realtime report within your GA4 property (Reports -> Realtime). If the setup is working, you should observe activity shortly after your Webfuse browsing session. Look specifically for:

  • Pageviews: Entries appearing under "Views by Page title and screen name" that match the titles or paths of the pages you visited on the third-party website (e.g., Amazon.com product pages).
  • Events: Primarily page_view events being registered concurrently with your test browsing.

After standard GA processing time (which can vary), the data should also appear in detailed reports.

Google Analytics 4 real-time dashboard showing tracked page views and events from third-party websites via Webfuse injection

Conclusion

This guide has walked through a technical approach to gaining deeper insights into user interactions on websites you don't own. By creating a simple Webfuse extension and leveraging the platform's web augmentation capabilities, we've demonstrated how it's possible to inject your own Google Analytics tracking code into third-party browsing sessions initiated through specific Webfuse links.

Related Articles