The Web Ratings
Going Deeper

Triggers

Ways to open the review widget in your app

The widget provides two built-in trigger methods. Beyond that, you can call TheWebRatings.open() from any custom logic you write.

Built-in Triggers

Programmatic

Call TheWebRatings.open() from any button, link, or event handler:

<button onclick="TheWebRatings.open('[email protected]', 'John Doe')">Leave a Review</button>

You can pass the user's email and name to pre-fill the review form, or call it without arguments to let the widget detect or ask for user info.

Auto-Prompt

The widget automatically opens after a configurable number of user sessions (default: 3). See Auto-Prompt for full configuration and backoff rules.

Custom Logic with Events

You can intercept successful submissions using the events system:

<script>
  TheWebRatings.on('rating:submitted', (data) => {
    console.log('Review submitted:', data.ratingId, data.rating);
  });
</script>

Integration Recipes

The examples below are patterns you implement in your own code — the widget itself just provides open(). These are not built-in features of the widget.

After a Key Interaction

<script>
  function onUserCompletedOnboarding() {
    TheWebRatings.open();
  }

  function onPurchaseComplete(orderId) {
    TheWebRatings.open();
  }
</script>

Time-Based

<script>
  // After 5 minutes of usage
  setTimeout(() => {
    TheWebRatings.open();
  }, 300000);
</script>

Frequency Limiting

<script>
  function shouldShowFeedback() {
    const lastShown = localStorage.getItem('twr_feedback_last_shown');
    const oneDay = 24 * 60 * 60 * 1000;

    if (!lastShown || Date.now() - parseInt(lastShown) > oneDay) {
      localStorage.setItem('twr_feedback_last_shown', Date.now().toString());
      return true;
    }
    return false;
  }

  function triggerWithLimit() {
    if (shouldShowFeedback()) {
      TheWebRatings.open();
    }
  }
</script>

Keyboard Shortcut

<script>
  document.addEventListener('keydown', (e) => {
    if (e.ctrlKey && e.shiftKey && e.key === 'F') {
      e.preventDefault();
      TheWebRatings.open();
    }
  });
</script>

Best Practices

  • Timing matters: Ask for reviews when users have context (after value delivery)
  • Don't overwhelm: Show review requests no more than once per session
  • Respect user choice: Always allow users to dismiss the modal
  • Track frequency: Use localStorage to prevent showing too often