Skip to main content
Track any user action as a conversion goal to measure what matters to your business.

What are goals?

Goals are custom events that you want to track, such as:
  • Button clicks
  • Form submissions
  • Video plays
  • File downloads
  • Newsletter signups
  • Product purchases
  • Any custom user action

Create a goal

Goals are auto-created when you track them. You can also predefine goals in the dashboard:
  1. Go to your website settings in the dashboard
  2. Click “Goals” in the sidebar
  3. Click “Create Goal”
  4. Enter:
    • Name - A descriptive name (e.g., “Newsletter Signup”)
    • Event - The event identifier (e.g., “newsletter_signup”)
    • Description - Optional description
Add this script to your HTML <head> to guarantee events are captured even when triggered before the main script loads:

Method 1: JavaScript

Simple goal (by name)

Goal with custom parameters

Rules for goal names:
  • Use lowercase letters
  • Numbers, underscores (_), and hyphens (-) are allowed
  • Maximum 64 characters
Rules for custom parameters:
  • Property names: lowercase letters, numbers, underscores (_), and hyphens (-) only. Max 64 characters.
  • Property values: any string, max 255 characters.
  • Maximum 10 custom parameters per event.

Goal with value

Method 2: HTML data attributes

Track goals automatically when users click elements with the data-postmetric-goal attribute.

Simple button

With custom parameters

Parameter names are converted from kebab-case to snake_case (e.g. data-postmetric-goal-product-idproduct_id).

Method 3: Server-side API

For best reliability (avoids ad blockers), track goals from your backend:

Using the v1 API (requires API key)

Using the tracking endpoint (uses cookies)

See our Goal API documentation for details.

Common goal examples

Form submission

Button click

Video play

File download

Test your setup

Visit /test-goals on your PostMetric instance to verify goal tracking works. Click the buttons to fire events and check your dashboard analytics.

Best practices

  1. Use descriptive event names - Use clear, consistent naming (e.g. newsletter_signup, not ns)
  2. Track meaningful actions - Focus on actions that matter to your business
  3. Include values when relevant - Add numeric values for revenue-related goals
  4. Prefer server-side for critical events - Newsletter signups and purchases are more reliable when tracked from the backend

Next steps

Track conversion funnels

Learn how to track multi-step conversion funnels