Gathering detailed insights and metrics for gatsby-remark-google-analytics-track-links
Gathering detailed insights and metrics for gatsby-remark-google-analytics-track-links
Gathering detailed insights and metrics for gatsby-remark-google-analytics-track-links
Gathering detailed insights and metrics for gatsby-remark-google-analytics-track-links
Track internal and external clicks from links embedded in your Gatsby markdown
npm install gatsby-remark-google-analytics-track-links
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
14 Commits
2 Watchers
5 Branches
2 Contributors
Updated on Apr 26, 2023
Latest Version
1.0.2
Package Id
gatsby-remark-google-analytics-track-links@1.0.2
Unpacked Size
12.58 kB
Size
4.88 kB
File Count
10
NPM Version
6.14.4
Node Version
12.18.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This is a Gatsby Remark plugin that provides the same tracking that gatsby-plugin-google-analytics
' (or gatsby-plugin-google-gtag
)s OutboundLink
and trackCustomEvent
accomplishes within your actual codebase: the ability to track link clicks to internal & external locations within your markdown. It provides an onClick
handler to all links that come from Markdown in your site.
With npm:
npm install --save gatsby-remark-google-analytics-track-links
or with yarn:
yarn add gatsby-remark-google-analytics-track-links
1// In gatsby-config.js 2plugins: [ 3 { 4 resolve: `gatsby-transformer-remark`, 5 options: { 6 plugins: [ 7 //... 8 `gatsby-remark-google-analytics-track-links`, 9 ], 10 }, 11 }, 12];
This plugin supports both the (now) legacy window.ga
tag, and the newer gtag
. If both tags exist on your site, events will be sent to both tags (with the assumption being that most sites will only have one version of the tag).
This plugin adds target="_blank" rel="noopener nofollow noreferrer"
properties by default to your external links, as well as a targetable class name ("siteLink"
by default). You can opt-out of adding the rel
attribute, if desired. Here are all the defaults:
1{ 2 allowFollowLinks: false, //set to true to remove the "rel" attribute entirely 3 className: "siteLink", 4 localLinkMatch: false, //otherwise should be a string / regex 5 gaOptions: { 6 internalLinkTitle: "Internal Link", //fallback for internal links if event category not passed 7 externalLinkTitle: "External Link", //fallback for external links if event category not passed 8 eventCategory: false, //pass a string to customize 9 eventAction: `click`, 10 eventLabel: false //pass a string to customize 11 }, 12 rel: "noopener nofollow noreferrer", //added to each anchor tag 13 runInDev: false, //update to true if your version of GA is available in dev and you want to test tracking 14 target: "_blank" // added to each anchor tag 15}
You can customize any of the options you would like; the others will be copied from the defaults:
1// In gatsby-config.js 2plugins: [ 3 { 4 resolve: `gatsby-transformer-remark`, 5 options: { 6 plugins: [ 7 //... 8 { 9 resolve: "gatsby-remark-google-analytics-track-links", 10 options: { 11 target: "someValue", 12 rel: "noopener noreferrer", 13 className: "theClassIdLikeInstead", 14 }, 15 }, 16 ], 17 }, 18 }, 19];
allowFollowLinks
: removes the rel
attribute entirely, allowing you to take advantage of "follow" linksclassName
: the class added to each anchor taglocalLinkMatch
: string or regex if you need additional matching options for catching internal links; I think most people end up using a combination of gatsby-remark-relative-links
and gatsby-plugin-catch-links
, but if you needed to catch "absolute-path-y" links in your Markdown that are in fact local links, then this option will let you properly flag the links as internal ones for your GA eventsgaOptions.internalLinkTitle
: if you aren't going to use your own custom event category this is the category that will be used for internal linksgaOptions.externalLinkTitle
: same but for external linksgaOptions.eventCategory
: supply this string to override the choices for internal / external link titlesgaOptions.eventAction
: "click" by default, or your own stringgaOptions.eventLabel
: if you don't supply your own string, defaults to event.currentTarget.href
; the URL of the link that was clicked, in other wordsrel
: defines the relationship from the current page to the linked page. Defaults to noopener nofollow noreferrer
for external links; is not added to internal linksrunInDev
: by default, this plugin does not run while in Dev mode; this mirrors the settings for gatsby-plugin-google-analytics
. If you are installing the GA tag on your own and want to test event sending in development, you can set this flag to true
to test. Otherwise, you can test by running gatsby build
and then gatsby serve
target
: where to open the link. Defaults to _blank
for external links; is not added for internal linksContributions are welcome, however I would ask that all feature requests come with additional tests added. You are also welcome to contribute in the way of adding tests, though heavy test refactors may be turned away unless there is a pressing need for said refactor. Additionally, I would ask that all PR's be submitted with the default prettier
formatting.
Thanks to:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/11 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More