Call Us NowRequest a Quote
Back to Blog
Next.js 15
July 25, 2024
15 min read

Architecting a Custom B2B Proxy Conversion Engine for Google Ads VBB with Next.js 15

Induji Technical Team

Induji Technical Team

Content Strategy

Architecting a Custom B2B Proxy Conversion Engine for Google Ads VBB with Next.js 15

Key Takeaways

  • The Problem: Google's Value-Based Bidding (VBB) strategies like tCPA and tROAS fail for high-ticket B2B advertisers due to low conversion volume (e.g., < 20 demo requests per month), starving the algorithm of necessary learning data.
  • The Solution: Architect and build a custom "Proxy Conversion Engine." This server-side system captures high-intent user micro-conversions (e.g., watching a demo, downloading a whitepaper), assigns them a monetary value, and fires them to the Google Ads API as server-to-server conversions.
  • The Technology: Next.js 15 is the ideal framework for this engine, using Server Actions for secure event ingestion, Vercel Edge/Serverless functions for scalable processing, and the App Router for creating robust API endpoints.
  • The Architecture: An event-driven approach using a message queue (like Upstash QStash or Vercel KV) decouples event ingestion from processing, ensuring data integrity, scalability, and resilience against API failures.
  • The Impact: This custom software provides the Google Ads algorithm with a high-frequency stream of valued bidding signals, enabling it to optimize for users who demonstrate real buying intent, dramatically improving lead quality and ROAS even with low final conversion counts.

The B2B Advertiser's Dilemma: Low Volume, High Stakes, and Flailing VBB

If you're in high-ticket B2B marketing, you know the frustration. Your company sells a complex product with a six-figure annual contract value. A single qualified lead can be worth thousands. You turn to Google Ads, the undisputed king of intent-based advertising, and are immediately pushed towards automated, Value-Based Bidding (VBB) strategies like Target CPA (tCPA) and Target ROAS (tROAS).

The problem is, these algorithms are data-hungry. They require a steady diet of 30-50 conversions per month per campaign to effectively learn and optimize. But your "Contact Sales" form might only get 10 submissions a month across the entire account. The result? The bidding algorithm thrashes. It either spends budget inefficiently, unable to find patterns, or it stops spending altogether, entering a state of "Learning (Limited)".

Standard agency advice falls short:

  • "Optimize for calls": Insufficient volume and often low-quality.
  • "Broaden your keywords": Kills intent and lead quality.
  • "Just use Manual CPC": You lose all the real-time, auction-level signal processing that makes modern Google Ads powerful.

This is a classic market failure where the platform's tooling is misaligned with the high-value, low-volume reality of B2B. The solution isn't to dumb down your strategy; it's to build smarter, custom infrastructure. This is where we architect a Proxy Conversion Engine.

Conceptual Blueprint: From User Signals to Bidding Signals

A Proxy Conversion Engine is a custom, server-side application that translates high-intent user behavior on your website into a stream of valued conversion signals for the Google Ads platform. It acts as an intelligence layer between your user and the ad algorithm.

Instead of only telling Google about the one user who filled out a form, you tell it about the twenty users who showed strong signs of buying intent. We call these "proxy conversions" or "weighted micro-conversions."

Examples of High-Intent Proxy Conversions:

  • Engagement: Spending more than 3 minutes on a critical case study page.
  • Consideration: Watching over 75% of an embedded product demo video.
  • Evaluation: Interacting with a pricing calculator or ROI estimation tool.
  • Research: Downloading a gated technical whitepaper or implementation guide.
  • Navigation: Visiting the Contact Us page but not submitting the form (a strong signal of intent with friction).

The core logic is to assign a nominal, but directionally correct, monetary value to each of these actions. For example:

  • Whitepaper Download: $5
  • Demo Video Watched (>75%): $15
  • Pricing Calculator Interaction: $25

These valued events are then sent server-to-server to the Google Ads API, complete with the gclid (Google Click Identifier). Google's algorithm now sees a rich stream of data. It learns that clicks leading to users who watch the demo video and use the pricing calculator are more valuable, and it begins to bid more aggressively to find more people like them.

A flowchart diagram illustrating the data flow: A user on a Next.js website clicks a 'Download Whitepaper' button. This action, along with the GCLID, is sent to a Next.js Server Action. The Server Action pushes the event to a message queue. A serverless function processes the event, assigns it a value of $5, and sends it to the Google Ads API as a new conversion.

Technical Architecture: Building the Engine with Next.js 15 and Event-Driven Principles

Next.js 15, with its deep integration of React 19 features and mature server-side capabilities, provides the perfect toolkit for building a robust, scalable, and secure proxy conversion engine.

The Core Stack: Why Next.js 15?

  • Server Actions: The cornerstone of our ingestion layer. They allow client components to securely call server-side functions without the boilerplate of creating traditional API routes. This is perfect for capturing a user event and its associated data (gclid, page_url) with a single, type-safe function call.
  • App Router & API Routes: For more complex scenarios or for receiving webhooks, the App Router's API routes provide a stable and powerful way to define server endpoints.
  • Serverless & Edge Functions: The entire engine can be deployed on Vercel or a similar platform, leveraging serverless functions that scale automatically. This is critical for handling event traffic without managing infrastructure. We can process events with minimal latency and cost.
  • Caching and Performance: While not the primary focus for an event-processing engine, Next.js 15's advanced caching primitives (unstable_cache, full route caching) ensure the user-facing part of the site remains lightning-fast, preventing event-tracking scripts from harming user experience.

Step 1: Event Ingestion and Capture

The first step is to reliably capture user interactions and, most importantly, the gclid.

  1. GCLID Persistence: On landing, grab the gclid from the URL parameters. Store it in a first-party, httpOnly cookie with a 90-day expiry. This is more robust than localStorage and ensures the GCLID is available for subsequent server-side calls.

  2. Client-Side Triggers: Use a lightweight client-side script or React's useEffect and IntersectionObserver to detect events. For example, to track a video view:

    // In a React component
    'use client';
    import { trackVideoWatch } from '@/app/actions'; // A Server Action
    
    function DemoVideoPlayer() {
      const videoRef = useRef(null);
    
      useEffect(() => {
        const video = videoRef.current;
        const handleTimeUpdate = () => {
          const percentageWatched = (video.currentTime / video.duration) * 100;
          if (percentageWatched > 75) {
            // Fire the server action once
            trackVideoWatch({ videoId: 'demo-2026' }); 
            video.removeEventListener('timeupdate', handleTimeUpdate);
          }
        };
        video.addEventListener('timeupdate', handleTimeUpdate);
        return () => video.removeEventListener('timeupdate', handleTimeUpdate);
      }, []);
    
      return <video ref={videoRef} controls src="/demo.mp4" />;
    }
    
  3. Server Action Ingestion: The trackVideoWatch server action receives the payload, automatically retrieves the gclid from the cookie, and prepares the data for processing.

    // app/actions.ts
    'use server';
    import { cookies } from 'next/headers';
    import { QStash } from '@upstash/qstash';
    
    const qstash = new QStash({ token: process.env.QSTASH_TOKEN });
    
    export async function trackVideoWatch(payload) {
      const cookieStore = cookies();
      const gclid = cookieStore.get('gclid')?.value;
    
      if (!gclid) {
        // No click ID, no attribution possible.
        return;
      }
    
      const eventData = {
        eventName: 'demo_video_watched_75',
        gclid: gclid,
        timestamp: new Date().toISOString(),
        ...payload,
      };
    
      // Push to a message queue instead of processing directly.
      await qstash.publishJSON({
        url: `${process.env.NEXT_PUBLIC_APP_URL}/api/process-conversion`,
        body: eventData,
      });
    }
    

Step 2: Event Processing and Validation (The "Brain")

Directly processing the conversion and calling the Google Ads API within the Server Action is risky. What if the Google Ads API is down? What if there's a sudden spike in traffic? The user's request could time out.

We use an event-driven architecture with a message queue for resilience and scalability.

  1. Message Queue: We use Upstash QStash (a serverless queue built on Redis) to decouple ingestion from processing. The Server Action's only job is to validate the input and publish a message to the queue. This is a sub-50ms operation.

  2. Processing Endpoint: Create a Next.js API route (/api/process-conversion) that QStash will call. This endpoint is secured to only accept requests from QStash.

  3. The Processor Logic: This is the core of the engine.

    // app/api/process-conversion/route.ts
    import { verifySignature } from '@upstash/qstash/nextjs';
    import { NextRequest, NextResponse } from 'next/server';
    
    async function handler(req: NextRequest) {
      const body = await req.json();
    
      // Define your conversion model
      const conversionModel = {
        'demo_video_watched_75': { value: 15.00, currency: 'USD', actionId: 'YOUR_VIDEO_ACTION_ID' },
        'whitepaper_download': { value: 5.00, currency: 'USD', actionId: 'YOUR_WHITEPAPER_ACTION_ID' },
      };
    
      const eventConfig = conversionModel[body.eventName];
      if (!eventConfig) {
        return NextResponse.json({ message: 'Unknown event' }, { status: 400 });
      }
    
      // TODO: Implement Google Ads API call
      // await sendConversionToGoogleAds({
      //   gclid: body.gclid,
      //   conversionAction: `customers/YOUR_CUSTOMER_ID/conversionActions/${eventConfig.actionId}`,
      //   conversionDateTime: body.timestamp,
      //   conversionValue: eventConfig.value,
      //   currencyCode: eventConfig.currency,
      // });
    
      console.log(`Processed conversion: ${body.eventName} with value ${eventConfig.value}`);
      return NextResponse.json({ success: true });
    }
    
    export const POST = verifySignature(handler);
    

A detailed architectural diagram. A browser sends a request to a Next.js Server Action. The Server Action publishes a JSON payload to an Upstash QStash queue. QStash triggers a Next.js API Route (serverless function)
. This function contains the business logic to value the event and makes an authenticated API call to the Google Ads API. A separate box shows a monitoring dashboard pulling logs.

Step 3: Firing Conversions via Google Ads API

This is the final, crucial step. Using a simple pixel won't work for this server-to-server model. You must use the official Google Ads API.

  1. Authentication: You'll need to set up a Google Cloud project, enable the Google Ads API, and create OAuth 2.0 credentials. For a server-to-server application, you'll use a service account or a refresh token flow. Store these credentials securely in environment variables.

  2. API Client: Use the official @google-ads/google-ads-client library for Node.js.

  3. Sending the Conversion: The UploadClickConversions method is what you'll use. You construct a ClickConversion object containing the gclid, the conversion_action resource name, the conversion_value, and the conversion_date_time.

    // A conceptual function for sending the conversion
    async function sendConversionToGoogleAds(data) {
      const client = new GoogleAdsApi({
        client_id: process.env.GOOGLE_CLIENT_ID,
        client_secret: process.env.GOOGLE_CLIENT_SECRET,
        developer_token: process.env.GOOGLE_DEVELOPER_TOKEN,
      });
      
      const customer = client.Customer({
        customer_id: 'YOUR_MCC_OR_CUSTOMER_ID',
        login_customer_id: 'YOUR_LOGIN_CUSTOMER_ID', // Often your MCC ID
        refresh_token: process.env.GOOGLE_REFRESH_TOKEN,
      });
    
      const conversionUploadService = customer.getService('ConversionUploadService');
      
      const clickConversion = {
        gclid: data.gclid,
        conversion_action: data.conversionAction,
        conversion_date_time: data.conversionDateTime.replace('Z', '+00:00'), // Format requirement
        conversion_value: data.conversionValue,
        currency_code: data.currencyCode,
      };
    
      await conversionUploadService.uploadClickConversions({
        customer_id: 'YOUR_CUSTOMER_ID',
        conversions: [clickConversion],
        partial_failure: true, // Recommended
      });
    }
    

SDLC and Implementation Best Practices

Defining Your Proxy Conversion Model

This is a strategic, not purely technical, exercise.

  1. Workshop: Get marketing, sales, and data stakeholders in a room. Map the entire buyer's journey from first touch to closed deal.
  2. Identify Signals: Pinpoint key actions on your website that correlate with a user moving down the funnel.
  3. Assign Initial Values: Start with conservative, relative values. A pricing page visit is worth more than a blog read. A demo video watch is worth more than a pricing page visit. Don't overthink the exact dollar amount initially; the relative weights are more important.
  4. Document: Create a clear document defining each proxy conversion, its trigger conditions, and its value. This becomes the specification for the development team.

Setting Up Google Ads Correctly

  1. Create New Actions: In your Google Ads account, create new, separate conversion actions for each proxy event (e.g., "Proxy - Whitepaper Download," "Proxy - Demo Watch").
  2. Set as "Secondary": Initially, set the "Goal and action optimization" for these new actions to "Secondary." This means Google will record them, but they won't be used for bidding. This allows you to collect data and validate the system without risking your budget.
  3. Validate: For a few weeks, monitor the proxy conversions coming in. Ensure they are being attributed to the correct campaigns and that the volumes seem reasonable.
  4. Promote to "Primary": Once you're confident the system is working, change the most significant proxy actions to "Primary" and add them to the conversion goal set your campaigns are optimizing towards. You can now switch your campaigns to tCPA or tROAS, and they will use this new, rich data stream.

Monitoring, Iteration, and Calibration

The engine is not a "set and forget" system. The real power comes from continuous improvement.

  • Build a Dashboard: Create a simple internal dashboard (it can even be a protected page in your Next.js app) that visualizes the proxy events being fired.
  • Correlation Analysis: On a monthly or quarterly basis, pull data from your CRM. Are the leads who triggered proxy events converting to sales-qualified leads (SQLs) and customers at a higher rate? If leads who watch the demo video close 50% more often, consider increasing the conversion value assigned to that action.
  • Feedback Loop: This analysis forms a feedback loop that continually refines the signals you're sending to Google, making your ad spend progressively more intelligent.

A screenshot of a conceptual Grafana or Vercel Data dashboard. It shows several time-series graphs: 'Proxy Conversions Fired per Hour', 'Event Type Distribution (Pie Chart)
', 'Average Proxy Conversion Value', and 'Google Ads API Latency'.

Avoiding Common Pitfalls

  • Data Pollution: Don't fire an event for every button click. Be selective. Each proxy conversion should represent a meaningful step in the buyer's journey. Firing too many low-intent signals will confuse the algorithm.
  • Value Inflation: Don't assign a $1000 value to a whitepaper download. The goal is to provide directional value and volume, not to perfectly model your funnel's economics on day one. Start low and adjust based on backend performance.
  • Ignoring the GCLID: The entire system hinges on capturing and passing the gclid correctly. Test your cookie implementation thoroughly across different browsers and devices.
  • API Rate Limits & Errors: The Google Ads API has rate limits. Your processing function must include error handling with an exponential backoff retry mechanism (which message queues like QStash provide out-of-the-box).

Frequently Asked Questions (FAQ)

Q1: Isn't this just the same as setting up event goals in Google Analytics and importing them? No, this is fundamentally different and more powerful. GA4 imports are often delayed (up to 24-48 hours), may be sampled, and don't provide the same granular, real-time signal. A direct server-to-server integration with the Google Ads API ensures every high-intent event is sent immediately and reliably, with a specific value, giving the bidding algorithm the fastest possible feedback loop.

Q2: How much development effort is a system like this? A proof-of-concept for a single event type can be built in a few days by an experienced Next.js developer. A full-fledged, production-ready system with multiple event types, a monitoring dashboard, and robust error handling is typically a 2-4 week project. The ROI, however, can be realized within the first month of activation.

Q3: How do we handle user consent and privacy (e.g., DPDP Act)? This architecture is privacy-forward. You are only using the gclid, a non-personally identifiable click identifier, for ad attribution. No PII (like email or name) is sent to Google. However, the use of cookies for storing the gclid and tracking user behavior still requires explicit user consent via a compliant cookie banner, in line with regulations like DPDP and GDPR.

Q4: Can this engine be used for other platforms like Meta Ads? Absolutely. The core event-driven architecture is platform-agnostic. The processor function can be extended to format the event data and send it to other APIs, such as the Meta Conversions API (CAPI). You would simply capture the fbc and fbp cookies alongside the gclid and call the relevant API in the processor. This allows you to build a single, unified conversion intelligence layer for all your marketing channels.

Supercharge Your B2B Advertising with a Custom Engine

Stop trying to force Google's consumer-focused bidding models to work for your high-value B2B sales cycle. The off-the-shelf tools have failed you because your business is unique.

Building a custom Proxy Conversion Engine is the definitive solution to make automated bidding work in a low-volume environment. It's a strategic investment in data infrastructure that pays dividends in the form of higher-quality leads, lower cost-per-acquisition, and a scalable, intelligent advertising program.

At Induji Technologies, we specialize in architecting and developing these exact types of custom, high-ROI MarTech solutions. We combine deep expertise in full-stack development with a strategic understanding of the B2B marketing landscape.

Ready to build an advertising engine that truly understands your customers?

Contact Induji Technologies for a consultation on your custom MarTech architecture today.

Related Articles

Ready to Transform Your Business?

Partner with Induji Technologies to leverage cutting-edge solutions tailored to your unique challenges. Let's build something extraordinary together.

Architecting a Custom B2B Proxy Conversion Engine for Google Ads VBB with Next.js 15 | Induji Technologies Blog