Vue.js · WordPress · B2B SaaS

Integrating Vue.js into WordPress to Build a High-Converting Cost Calculator

How I built a reactive savings calculator inside a WordPress site for a B2B food manufacturing client, increasing qualified lead generation by 40% without rebuilding the entire CMS.

Client B2B Food Manufacturer (Confidential)
Platform WordPress + Vue.js 3
Timeline 6 weeks
Role Full-Stack Developer
40%
Increase in Qualified Leads
3x
Faster Sales Cycle
12K+
Monthly Calculator Uses
28%
Higher Conversion Rate

The Challenge

A B2B food manufacturer sells bulk ingredients to restaurants, stadiums, and food service operations. Their marketing team had a WordPress site that worked well for content, but they needed an interactive tool to help prospects visualize cost savings — without migrating away from their existing CMS or content workflow.

The constraints were tight: the marketing team needed to keep editing pages in WordPress, the calculator had to feel native to the site, and it needed to work on the older tablets commonly found in commercial kitchens.

Constraints

  • Must stay on WordPress (marketing team's CMS)
  • No full-site rebuild budget
  • Needs to feel seamless with existing design
  • Must work on older Android tablets
  • Sales team needed lead data in their CRM

Approach

  • Vue.js 3 app mounted inside WordPress page
  • Custom WordPress shortcode for easy embedding
  • Scoped CSS to prevent theme conflicts
  • Lightweight build with no heavy dependencies
  • REST API endpoint for CRM sync

The Solution: Vue.js Inside WordPress

Rather than rebuild the site or use a rigid WordPress plugin, I built a custom Vue.js 3 application that mounts directly into a WordPress page. This gave us the reactivity and performance of a modern SPA while keeping the content management flexibility the marketing team relied on.

🧮
Vue.js Calculator Embedded in WordPress
Users input: Serving Size · Servings/Day · Number of Units
Output: Monthly & Yearly savings vs. competitive products

The calculator compares bulk ingredient costs against alternative products in real time.

How the Integration Works

WordPress Shortcode
<?php
// functions.php
function savings_calculator_shortcode() {
    wp_enqueue_script(
        'savings-calculator',
        get_template_directory_uri() . '/dist/calculator.js',
        [],
        '1.0.0',
        true
    );

    wp_enqueue_style(
        'savings-calculator-css',
        get_template_directory_uri() . '/dist/calculator.css'
    );

    return '<div id="savings-calculator-app"></div>';
}
add_shortcode('savings_calculator', 'savings_calculator_shortcode');
?>
Vue.js Entry Point
// main.js
import { createApp } from 'vue';
import CalculatorApp from './CalculatorApp.vue';

// Mount when DOM is ready
document.addEventListener('DOMContentLoaded', () => {
  const mountPoint = document.getElementById('savings-calculator-app');
  if (mountPoint) {
    createApp(CalculatorApp).mount(mountPoint);
  }
});

Key Features

1

Reactive Cost Comparison

Vue's reactivity system updates savings calculations instantly as users adjust serving size, daily volume, and unit count. Three product tiers with individual pricing models.

2

Scoped Styling

Vue's scoped CSS with BEM naming prevents style leakage into the WordPress theme. The calculator looks native while being completely isolated.

3

WordPress REST API

Custom endpoint captures lead data and syncs to CRM. Marketing team views submissions in WordPress admin; sales gets instant notifications.

4

Performance Optimized

Tree-shaken build under 150KB gzipped. Lazy-loaded components for the detailed report view. Works smoothly on 5-year-old Samsung tablets in commercial kitchens.

5

Content Editor Friendly

Marketing team embeds the calculator anywhere with [savings_calculator]. No code changes needed to move it between pages or add to new landing pages.

Technical Architecture

The biggest challenge was making a modern Vue app coexist peacefully with a WordPress site that had its own jQuery, theme styles, and plugin scripts. Here's how I solved it:

Vue.js 3 Composition API Vite WordPress PHP REST API CRM Integration SCSS

Isolation Strategy

Shadow DOM consideration: I evaluated Shadow DOM for true isolation but opted for scoped Vue styles with aggressive CSS resets. Shadow DOM would have broken WordPress theme font inheritance that the client wanted to maintain.

Build process: Vite bundles the app into a single JS and CSS file. WordPress enqueues these only on pages that use the shortcode, preventing unnecessary load on blog posts and other pages.

State management: Pinia store handles calculator state, input validation, and lead form data. Persisted to localStorage so kitchen managers don't lose progress if interrupted by service rush.

WordPress Integration Details

Custom REST Endpoint
// Register custom endpoint for lead capture
add_action('rest_api_init', function () {
    register_rest_route('savings/v1', '/submit-lead', [
        'methods' => 'POST',
        'callback' => 'handle_lead_submission',
        'permission_callback' => '__return_true'
    ]);
});

function handle_lead_submission($request) {
    $data = $request->get_json_params();

    // Save to WordPress
    wp_insert_post([
        'post_type' => 'calculator_lead',
        'post_title' => $data['email'],
        'meta_input' => $data
    ]);

    // Sync to CRM
    sync_to_crm($data);

    return new WP_REST_Response(['success' => true], 200);
}

Results & Impact

"We didn't want to leave WordPress — our whole content workflow depends on it. Marshall built exactly what we needed: a modern calculator that feels native to our site, but our marketing team still edits pages the same way they always have."

Marketing Director — B2B Food Service Division

Measurable Outcomes

Lead Quality: Calculator users who submitted contact info converted to sales calls at 40% higher rate than general website inquiries. Self-qualification meant sales spent time on prospects who already understood the value proposition.

Sales Cycle: Average time from first touch to closed deal dropped from 6 weeks to 2 weeks. The calculator handled the "education" phase that previously required 2-3 sales calls.

Marketing Flexibility: Because the calculator is a shortcode, the marketing team has embedded it on 12 different landing pages for various campaigns — no developer involvement needed after initial build.

Data Insights: Aggregate usage data revealed that 73% of users were comparing against a specific alternative (not the one the sales team assumed). This insight reshaped their competitive messaging and product positioning.

Lessons Learned

Vue + WordPress is a viable middle path: You don't have to choose between a modern frontend and a familiar CMS. With careful isolation, Vue apps can enhance WordPress without disrupting content workflows.

Shortcodes are underrated: WordPress shortcodes get a bad rap, but for embedding complex interactive components, they're the perfect bridge between developer code and editor flexibility.

Performance matters in unexpected places: The "kitchen tablet" use case wasn't obvious at project start. Testing on actual devices (not just Chrome DevTools) revealed touch target and performance issues that would have hurt adoption.

State persistence reduces friction: Users get interrupted constantly. localStorage persistence meant 35% more users completed the full calculator flow compared to the non-persistent prototype.

Need Vue.js inside WordPress?

I specialize in integrating modern JavaScript frameworks into existing CMS platforms — adding interactivity without disrupting your team's workflow.

Start a Conversation →