Framework Guides

Ours Privacy Integration with Lovable

Step-by-step guide to integrate Ours Privacy, built for HIPAA-regulated workflows, with a Lovable-built app to track page views and custom events.

This guide covers adding Ours Privacy tracking to an app built with Lovable, an AI app builder that generates a React codebase you can edit directly.

Integration Options

Lovable projects are standard Vite + React single-page applications, so the same options apply as any React app:

The guide below covers pasting the Ours Privacy Web SDK snippet directly into your project.

For a no-code approach that doesn't require touching index.html, use the Ours Privacy Tag Manager instead.


Steps to Integrate Ours with Lovable

1. Add the Web SDK snippet

  1. Copy your install snippet from the Install Ours page.
  2. Open your Lovable project's code editor (or use Lovable's chat and ask it to make the edit for you) and open index.html at the project root.
  3. Paste the snippet inside the <head> section, before the closing </head> tag.
<!-- index.html -->
<head>
  <!-- Ours Pixel Code -->
  <script>
    // your install code is here
  </script>
  <!-- End Ours Pixel Code -->
</head>

The Web SDK tracks page views automatically, both on initial load and on subsequent client-side route changes, so no additional routing code is required.

2. Publish and verify

  1. Publish your Lovable project.
  2. Visit the published site and open the browser console to check for script errors.
  3. In your Ours account, check Recent Events to confirm page views are coming through.

Track Custom Events

Call window.ours('track', ...) from any component's event handler:

function SignUpButton() {
  const handleClick = () => {
    if (typeof window !== 'undefined' && window.ours) {
      window.ours('track', 'ButtonClicked', { button_name: 'sign_up' });
    }
  };

  return <button onClick={handleClick}>Sign Up</button>;
}

Next Steps

If you need further assistance, contact us at support@oursprivacy.com.

How is this guide?

On this page