
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@tryghost/referrer-parser
Advanced tools
A simple library for parsing referrer URLs to identify their source and medium.
npm install @tryghost/referrer-parser
# or
yarn add @tryghost/referrer-parser
const { parse } = require('@tryghost/referrer-parser');
// Parse a referrer URL
const result = parse('https://www.google.com/search?q=ghost+cms');
console.log(result);
// {
// referrerSource: 'Google',
// referrerMedium: 'search',
// referrerUrl: 'www.google.com'
// }
const { parse } = require('@tryghost/referrer-parser');
// Parse with site configuration to detect internal traffic
const result = parse(
'https://example.com/blog?utm_source=newsletter&utm_medium=email',
{
siteUrl: 'https://example.com',
adminUrl: 'https://example.com/ghost'
}
);
For more advanced usage, you can use the ReferrerParser class directly:
const { ReferrerParser } = require('@tryghost/referrer-parser');
// Create a parser instance
const parser = new ReferrerParser({
siteUrl: 'https://example.com',
adminUrl: 'https://example.com/ghost'
});
// Parse multiple URLs with the same configuration
const result1 = parser.parse('https://www.google.com/search?q=ghost+cms');
const result2 = parser.parse('https://twitter.com/ghostcms');
This package is fully written in TypeScript and provides its own type definitions.
import { parse, ReferrerParser, ReferrerData, ParserOptions } from '@tryghost/referrer-parser';
// Parse a referrer URL with type safety
const result: ReferrerData = parse('https://www.google.com/search?q=ghost+cms');
console.log(result.referrerSource); // 'Google'
console.log(result.referrerMedium); // 'search'
console.log(result.referrerUrl); // 'www.google.com'
// Configure the parser with typed options
const options: ParserOptions = {
siteUrl: 'https://example.com',
adminUrl: 'https://example.com/ghost'
};
// Create a parser instance with TypeScript
const parser = new ReferrerParser(options);
const customResult = parser.parse('https://example.com/blog?utm_source=newsletter');
MIT
Run the tests with:
yarn test
This will run the test suite using Mocha and report on test coverage.
FAQs
Simple library for parsing referrer URLs
The npm package @tryghost/referrer-parser receives a total of 0 weekly downloads. As such, @tryghost/referrer-parser popularity was classified as not popular.
We found that @tryghost/referrer-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 29 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.