Trakg works seamlessly with React by using a simple <script> tag that tracks all form interactions β€” including abandoned fields. You don’t need to modify your form structure or write any special handlers.

πŸ“¦ Where to add the script

In most React apps created with Create React App (CRA), the best place to add the Trakg script is inside the public/index.html file. Paste the following line before the closing </body> tag inside public/index.html:
<!-- Trakg Script -->
<script
  src="https://cdn.trakg.com/api/v1/tracker.min.js?id=YOUR_ID_GIVEN"
></script>
πŸ” Replace YOUR_ID_GIVEN with the unique Site ID from your Trakg dashboard.

πŸ“ Full Example: public/index.html

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>My React App</title>
	</head>
	<body>
		<div id="root"></div>

		<!-- βœ… Trakg script just before closing body -->
		<script
			defer
			src="https://cdn.trakg.com/api/v1/tracker.min.js?id=YOUR_ID_GIVEN"
		></script>
	</body>
</html>

πŸ›‘ Best Practices

βœ… Always use the defer attribute β€” it ensures the script loads after HTML is parsed
βœ… Keep the script at the end of the <body> for non-blocking performance
βœ… No need to wrap your form with providers or HOCs β€” Trakg works with standard HTML form tags
βœ… Works with any form built using form, input, textarea, or select

πŸš€ You’re Ready!

Once installed, visit your Trakg dashboard to:
  • View partial and completed leads
  • See real-time form activity
  • Export your lead data anytime