Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

16.1 KB
Raw Blame
import { TrendUpIcon } from '@phosphor-icons/react'
import { useState } from 'react'
import type { MetaFunction } from 'react-router'
import { redirect } from 'react-router'
import type { SitemapFunction } from 'remix-sitemap'

import { DitchGoogle } from '~/components/marketing/DitchGoogle'
import { ToolsNav, ToolsNavMobile } from '~/components/ToolsNav'
import { getOgImageUrl, isSelfhosted } from '~/lib/constants'
import Button from '~/ui/Button'
import Input from '~/ui/Input'
import { FAQ } from '~/ui/FAQ'
import { Text } from '~/ui/Text'
import { getDescription, getPreviewImage, getTitle } from '~/utils/seo'

export const meta: MetaFunction = () => {
  const title = 'Free CTR Calculator tool - Calculate your CTR'
  const description =
    'Calculate click-through rate from clicks and impressions, compare CTR, and learn how to measure and improve campaign performance.'
  return [
    ...getTitle(title),
    ...getDescription(description),
    ...getPreviewImage(getOgImageUrl(title, description)),
  ]
}

export const sitemap: SitemapFunction = () => ({
  priority: 0.8,
  exclude: isSelfhosted,
})

export async function loader() {
  if (isSelfhosted) {
    return redirect('/login', 302)
  }

  return null
}

const FAQ_ITEMS = [
  {
    question: 'What is CTR (Click-Through Rate)?',
    answer:
      'CTR is a metric that measures the percentage of people who click on your ad or link after seeing it. It helps you understand how compelling and relevant your content is to your audience.',
  },
  {
    question: 'What is a good CTR?',
    answer:
      'A good CTR varies by industry and platform. For Google Ads, 2-3% is average for search ads. Display ads typically see 0.5-1%. Facebook ads average 0.9%, while email campaigns can achieve 2-5%. Higher CTRs indicate more engaging content.',
  },
  {
    question: 'How do I improve my CTR?',
    answer:
      'Improve CTR by writing compelling headlines, using relevant keywords, creating clear calls-to-action, A/B testing ad copy, targeting the right audience, and using eye-catching visuals. Regular optimization based on performance data is key.',
  },
  {
    question: 'Why is CTR important?',
    answer:
      'CTR directly impacts your advertising costs and effectiveness. Higher CTRs lead to better Quality Scores in Google Ads, lower cost-per-click, improved ad rankings, and ultimately better ROI on your marketing spend.',
  },
  {
    question: 'How is CTR calculated?',
    answer:
      'CTR is calculated by dividing the total number of clicks by the total number of impressions, then multiplying by 100 to get a percentage. Formula: CTR = (Clicks ÷ Impressions) × 100',
  },
  {
    question: 'What affects CTR?',
    answer:
      'CTR is influenced by ad relevance, headline quality, visual appeal, targeting accuracy, ad placement, timing, competition, and device type. Understanding these factors helps optimize your campaigns.',
  },
  {
    question: 'Can Swetrix track CTR for my campaigns?',
    answer:
      'Yes! Swetrix provides comprehensive analytics to track your marketing campaigns, including custom events for clicks and impressions. You can monitor CTR trends, compare campaigns, and get actionable insights to improve performance.',
  },
  {
    question: 'What is the difference between CTR and conversion rate?',
    answer:
      'CTR measures the percentage of people who click your ad after seeing it, while conversion rate measures the percentage of visitors who complete a desired action (purchase, signup, etc.) after clicking. Both metrics are crucial for campaign success.',
  },
]

interface CTRMetrics {
  clicks: string
  impressions: string
}

interface CTRResult {
  ctr: number
  performance: 'Excellent' | 'Good' | 'Average' | 'Below Average' | 'Poor'
  color: string
}

export default function CTRCalculator() {
  const [metrics, setMetrics] = useState<CTRMetrics>({
    clicks: '',
    impressions: '',
  })
  const [result, setResult] = useState<CTRResult | null>(null)

  const handleMetricChange = (key: keyof CTRMetrics, value: string) => {
    const newMetrics = { ...metrics, [key]: value }
    setMetrics(newMetrics)

    if (newMetrics.clicks && newMetrics.impressions) {
      const clicks = parseFloat(newMetrics.clicks)
      const impressions = parseFloat(newMetrics.impressions)

      if (clicks >= 0 && impressions > 0) {
        const ctr = (clicks / impressions) * 100

        let performance: CTRResult['performance']
        let color: string

        if (ctr >= 5) {
          performance = 'Excellent'
          color = 'text-green-600 dark:text-green-400'
        } else if (ctr >= 3) {
          performance = 'Good'
          color = 'text-blue-600 dark:text-blue-400'
        } else if (ctr >= 1.5) {
          performance = 'Average'
          color = 'text-yellow-600 dark:text-yellow-400'
        } else if (ctr >= 0.5) {
          performance = 'Below Average'
          color = 'text-orange-600 dark:text-orange-400'
        } else {
          performance = 'Poor'
          color = 'text-red-600 dark:text-red-400'
        }

        setResult({ ctr, performance, color })
      } else {
        setResult(null)
      }
    } else {
      setResult(null)
    }
  }

  // Using native <details>/<summary> for FAQ to ensure content is present in the DOM for SEO

  const reset = () => {
    setMetrics({ clicks: '', impressions: '' })
    setResult(null)
  }

  return (
    <div className='min-h-screen bg-gray-50 dark:bg-slate-950'>
      <main className='mx-auto max-w-7xl px-4 py-12 sm:px-6 lg:px-8'>
        <ToolsNavMobile className='mb-6 lg:hidden' />

        <div className='lg:flex lg:items-start lg:gap-8'>
          <div className='min-w-0 lg:flex-1'>
            <Text as='h1' size='4xl' weight='bold' tracking='tight'>
              CTR Calculator
            </Text>
            <Text as='p' size='lg' colour='muted' className='mt-4'>
              Calculate your Click-Through Rate and understand your campaign
              performance instantly
            </Text>

            <div className='mt-12 rounded-lg bg-white p-8 ring-1 ring-gray-200 dark:bg-slate-950 dark:ring-slate-800'>
              <div className='space-y-6'>
                <div>
                  <Text as='h2' size='2xl' weight='semibold' className='mb-6'>
                    Calculate Your CTR
                  </Text>

                  <div className='grid gap-6 md:grid-cols-2'>
                    <div>
                      <Input
                        type='number'
                        placeholder='Enter number of clicks'
                        label='Total Clicks'
                        value={metrics.clicks}
                        onChange={(e) =>
                          handleMetricChange('clicks', e.target.value)
                        }
                        className='w-full'
                        min='0'
                      />
                      <Text as='p' size='sm' colour='muted' className='mt-1'>
                        How many times your ad was clicked
                      </Text>
                    </div>

                    <div>
                      <Input
                        type='number'
                        placeholder='Enter number of impressions'
                        label='Total Impressions'
                        value={metrics.impressions}
                        onChange={(e) =>
                          handleMetricChange('impressions', e.target.value)
                        }
                        className='w-full'
                        min='1'
                      />
                      <Text as='p' size='sm' colour='muted' className='mt-1'>
                        How many times your ad was shown
                      </Text>
                    </div>
                  </div>

                  <div className='mt-6'>
                    <Button onClick={reset}>Reset</Button>
                  </div>
                </div>

                {result ? (
                  <div className='border-t border-gray-200 pt-6 dark:border-gray-700'>
                    <Text as='h3' size='lg' weight='medium' className='mb-4'>
                      Results
                    </Text>

                    <div className='rounded-lg bg-gray-50 p-6 dark:bg-slate-700/50'>
                      <div className='text-center'>
                        <div className='text-5xl font-bold text-gray-900 dark:text-white'>
                          {result.ctr.toFixed(2)}%
                        </div>
                        <div className='mt-2 text-lg text-gray-600 dark:text-gray-400'>
                          Click-Through Rate
                        </div>
                        <div
                          className={`mt-4 text-lg font-semibold ${result.color}`}
                        >
                          {result.performance} Performance
                        </div>
                      </div>

                      <div className='mt-6 grid gap-4 text-sm md:grid-cols-2'>
                        <div className='rounded-lg bg-white p-4 dark:bg-slate-800'>
                          <div className='text-gray-500 dark:text-gray-400'>
                            Formula Used
                          </div>
                          <div className='mt-1 font-mono text-gray-900 dark:text-white'>
                            CTR = (Clicks ÷ Impressions) × 100
                          </div>
                        </div>
                        <div className='rounded-lg bg-white p-4 dark:bg-slate-800'>
                          <div className='text-gray-500 dark:text-gray-400'>
                            Your Calculation
                          </div>
                          <div className='mt-1 font-mono text-gray-900 dark:text-white'>
                            ({metrics.clicks} ÷ {metrics.impressions}) × 100
                          </div>
                        </div>
                      </div>
                    </div>

                    <div className='mt-6 rounded-lg bg-indigo-50 p-4 dark:bg-indigo-900/20'>
                      <Text
                        as='h4'
                        size='lg'
                        weight='medium'
                        className='flex items-center text-indigo-900 dark:text-indigo-300'
                      >
                        <TrendUpIcon className='mr-2 h-5 w-5' />
                        Performance Insights
                      </Text>
                      <Text
                        as='p'
                        size='sm'
                        className='mt-2 text-indigo-800 dark:text-indigo-200'
                      >
                        {result.performance === 'Excellent'
                          ? 'Outstanding CTR! Your ads are highly engaging and relevant to your audience. Keep up the great work!'
                          : null}
                        {result.performance === 'Good'
                          ? 'Good CTR! Your ads are performing well. Consider A/B testing to push performance even higher.'
                          : null}
                        {result.performance === 'Average'
                          ? "Average CTR. There's room for improvement. Try refining your targeting or ad copy."
                          : null}
                        {result.performance === 'Below Average'
                          ? 'Below average CTR. Consider reviewing your ad relevance, targeting, and creative elements.'
                          : null}
                        {result.performance === 'Poor'
                          ? 'Low CTR indicates your ads may not be resonating with your audience. Consider a comprehensive review of your campaign strategy.'
                          : null}
                      </Text>
                    </div>
                  </div>
                ) : null}
              </div>
            </div>

            <section className='mt-20 border-t border-gray-200 pt-16 dark:border-slate-700'>
              <Text as='h2' size='3xl' weight='bold' tracking='tight'>
                Free Click-Through Rate (CTR) Calculator
              </Text>
              <Text
                as='p'
                size='lg'
                colour='muted'
                className='mt-4 leading-relaxed'
              >
                Use our free CTR calculator to instantly evaluate the
                performance of your search ads, display banners, or email
                campaigns. Click-through rate is a foundational metric that
                reveals how relevant and engaging your content is to your target
                audience.
              </Text>

              <div className='mt-12 grid gap-x-12 gap-y-10 md:grid-cols-2'>
                <div>
                  <Text as='h3' size='xl' weight='semibold'>
                    Why Does CTR Matter?
                  </Text>
                  <ul className='mt-3 space-y-2'>
                    <li>
                      <Text colour='muted'>
                        <Text as='span' weight='semibold' colour='inherit'>
                          Quality Score Impact
                        </Text>{' '}
                        - Higher CTRs typically lead to better Quality Scores on
                        platforms like Google Ads, which lowers your cost per
                        click (CPC).
                      </Text>
                    </li>
                    <li>
                      <Text colour='muted'>
                        <Text as='span' weight='semibold' colour='inherit'>
                          Relevance Indicator
                        </Text>{' '}
                        - A low CTR is a strong signal that your messaging,
                        targeting, or creative needs adjustment.
                      </Text>
                    </li>
                    <li>
                      <Text colour='muted'>
                        <Text as='span' weight='semibold' colour='inherit'>
                          Engagement Metric
                        </Text>{' '}
                        - For organic content and email marketing, CTR is the
                        best way to measure audience engagement.
                      </Text>
                    </li>
                  </ul>
                </div>
                <div>
                  <Text as='h3' size='xl' weight='semibold'>
                    Tips for Improving CTR
                  </Text>
                  <ul className='mt-3 space-y-2'>
                    <li>
                      <Text colour='muted'>
                        <Text as='span' weight='semibold' colour='inherit'>
                          Write compelling copy
                        </Text>{' '}
                        - Use action-oriented language and highlight clear
                        benefits or offers.
                      </Text>
                    </li>
                    <li>
                      <Text colour='muted'>
                        <Text as='span' weight='semibold' colour='inherit'>
                          Refine your audience
                        </Text>{' '}
                        - Ensure your ads are only shown to highly relevant
                        users.
                      </Text>
                    </li>
                    <li>
                      <Text colour='muted'>
                        <Text as='span' weight='semibold' colour='inherit'>
                          Test different creatives
                        </Text>{' '}
                        - Run A/B tests on headlines, images, and
                        calls-to-action (CTAs).
                      </Text>
                    </li>
                  </ul>
                </div>
              </div>
            </section>

            <div className='mt-16'>
              <Text
                as='h2'
                size='3xl'
                weight='bold'
                className='mb-8 text-center'
              >
                Frequently Asked Questions
              </Text>

              <FAQ items={FAQ_ITEMS} withStructuredData />
            </div>

            <DitchGoogle />
          </div>

          <aside className='hidden lg:sticky lg:top-12 lg:block lg:w-64 lg:shrink-0 lg:self-start'>
            <ToolsNav />
          </aside>
        </div>
      </main>
    </div>
  )
}