
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@frontity/google-analytics
Advanced tools
@frontity/google-analytics
Analytics package to use Google Analytics with Frontity
npm i @frontity/google-analytics
The namespace for this package is googleAnalytics
Every Google Analytics account has a Tracking ID.
To connect the package with a specific account (or accounts) we can set the following properties in the frontity.settings.js
:
state.googleAnalytics.trackingId
: to specify just one tracking IDstate.googleAnalytics.trackingIds
: to specify a list of tracking ID'sexport default {
packages: [
{
name: "@frontity/google-analytics",
state: {
googleAnalytics: {
trackingId: "UA-12345678-9",
},
},
},
],
};
export default {
packages: [
{
name: "@frontity/google-analytics",
state: {
googleAnalytics: {
trackingIds: ["UA-34567890-12", "UA-34567890-13"],
},
},
},
],
};
This @frontity/google-analytics
package can co-exist with some other analytics
packages. Once we have properly installed and configured these analytics
packages, their actions will be centralized by the analytics
namespace
actions.analytics.pageview()
will take into account settings in state.analytics.pageviews
actions.analytics.event()
will take into account settings in state.analytics.events
Read More info about how to use Analytic packages in the docs
actions.analytics.pageview
If @frontity/google-analytics
is configured and enabled for pageviews in state.analytics.pageviews
, every time a link changes (or every time action.router.set(link)
is launched) a tracking for that page will be sent to Google Analytics by using internally actions.analytics.pageview()
actions.analytics.event
If @frontity/google-analytics
is configured and enabled for events in state.analytics.events
, every time you call the method actions.analytics.event()
from any of your React components, the proper tracking info will be sent to Google Analytics.
The actions.analytics.event()
must receive an event object with the following properties.
Name | Type | Default | Required | Description |
---|---|---|---|---|
name | string | - | true | The value of this property is mapped to the eventAction field of analytics.js events. |
payload | Object | - | true | Event payload. |
The payload
object has to have the following format:
Name | Type | Default | Required | Description |
---|---|---|---|---|
category | string | - | true | The value of this property is mapped to the eventCategory field of analytics.js events. |
label | string | - | false | The value of this property is mapped to the eventLabel field of analytics.js events. |
value | number | - | false | The value of this property is mapped to the eventValue field of analytics.js events. |
[key] | any | - | false | Any other property specified in analytics.js field reference. |
These values will be transfomed (by this package) into the proper format before sending the data to Google Analytics
Feature Discussions about Frontity are public. You can join the discussions, vote for those you're interested in or create new ones.
These are the ones related to this package: https://community.frontity.org/tags/c/feature-discussions/33/google-analytics
Have a look at the latest updates of this package in the CHANGELOG
Frontity has a number of different channels at your disposal where you can find out more information about the project, join in discussions about it, and also get involved:
@frontity
.Got questions or feedback about Frontity? We'd love to hear from you in our community forum.
Frontity also welcomes contributions. There are many ways to support the project! If you don't know where to start then this guide might help: How to contribute?.
If you would like to start contributing to the code please open a pull request to address one of our good first issues.
FAQs
Analytics package to use Google Analytics with Frontity
We found that @frontity/google-analytics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.