Webfuse - The web augmentation platform | Product Hunt
Ideas
7
min read

How to Add Google Analytics to Any Website Using Webfuse

Tony Zedginidze profile pic
Tony Zedginidze

Learn how to inject your Google Analytics tracking code into any website—even ones you don’t own—using Webfuse. This step-by-step guide walks you through creating a custom browser extension, setting up your Webfuse Space, and tracking user interactions on third-party sites like Amazon or BestBuy. Perfect for marketers, analysts, and growth hackers looking for deeper insights into user behavior across the web.

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.

  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 <head>. 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.

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

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

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

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

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

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

select the entire folder.

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

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.

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

We can now close the settings panel.

And terminate the current session.

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.

How Webfuse Links Activate Your Analytics Injection

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

  • Link structure looks like this: https://webfuse.com/+yourspace/?url=https://targetsite.com
  • Example: https://webfuse.com/+analytics/?url=https://amazon.com

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.

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.

Extend the web instantly

Try webfuse for yourself!