Add rustalytics to any website with plain JavaScript in under 5 minutes
Add the rustalytics script to your HTML:
<script>
  (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'projectId':i});
  var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
  j.async=true;j.src='https://cdn.rustalytics.dev/v1.js';
  f.parentNode.insertBefore(j,f);
  })(window,document,'script','rustalytics','your-project-id');
</script>Add this script to the <head> of your HTML for best performance.
1. Track page views (automatic):
// Page views are tracked automatically
// No additional code needed!2. Track custom events:
// Track a button click
rustalytics.track('button_clicked', {
  buttonId: 'signup-button',
  page: 'homepage'
});
// Track form submission
rustalytics.track('form_submitted', {
  formId: 'contact-form',
  success: true
});3. Track user identification:
// Identify a user
rustalytics.identify('user123', {
  name: 'John Doe',
  email: 'john@example.com',
  plan: 'premium'
});window.RUSTALYTICS_CONFIG = {
  endpoint: 'https://your-custom-endpoint.com'
};window.RUSTALYTICS_CONFIG = {
  autoTrack: false
};For SPAs, manually track route changes:
// Track page view manually
rustalytics.pageView({
  path: '/new-route',
  title: 'New Page Title'
});If you need any help with the integration, feel free to: