@frontity/google-tag-manager-analytics
Last updated
Was this helpful?
Last updated
Was this helpful?
Analytics package to use with Frontity
The for this package is googleTagManagerAnalytics
Every Google Tag Manager account has a .
To connect the package with a specific account (or accounts) we can set the following properties in the frontity.settings.js
:
state.googleTagManagerAnalytics.containerId
: to specify just one container ID
state.googleTagManagerAnalytics.containerIds
: to specify a list of container ID's
This @frontity/google-tag-manager-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
actions.analytics.pageview
If @frontity/google-tag-manager-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 Tag Manager.
pageviews
to Google Analytics via Google Tag ManagerTrigger
Tag
actions.analytics.event
If @frontity/google-tag-manager-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 Tag Manager.
The actions.analytics.event()
must receive an event object with the following properties.
Name
Type
Required
Description
name
string
yes
The value of this property is mapped to the event
field of the object sent to GTM
payload
object
yes
Event payload.
You can add any info you want in the payload
object.
These values will be transfomed (by this package) into the proper format before sending the data to Google Tag Manager
Read more about how to use Analytic packages
In order to send pageviews to Google Analytics through Google Tag Manager in a Frontity project you have to create a Trigger listening to a custom event named pageview
, instead of the default pageview
(). This custom event is automatically send by @frontity/google-tag-manager-analytics package
In the you have just in case you need it for your