google-tag-manager

React SPA - GTM Analytics React-Helmet Previous Page Title

微笑、不失礼 提交于 2021-02-18 17:46:06
问题 I am using Google Tag Manager to push pageview events to the datalayer for Analytics tracking. This is happening in componentDidMount() (and sometimes componentWillReceiveProps() if I am listening for query string parameter changes with the location prop using withRouter). I am using react-helmet to dynamically update my title and other tags as components change. I have noticed an issue that I am getting the improper page title in Analytics. It's frequently showing the page title of the

How to set up Google Analytics through Google Tag Manager for Next-Js?

∥☆過路亽.° 提交于 2021-02-18 05:05:20
问题 formerly I was using react-ga npm module to insert google analytics in my next js app. and It was simply like this: import ReactGA from 'react-ga' export const initGA = () => { ReactGA.initialize('UA-*******-*', { titleCase: false }) } export const logPageView = () => { if (window.location.href.split('?')[1]) { ReactGA.set({page: window.location.pathname + '?' + window.location.href.split('?')[1]}) ReactGA.pageview(window.location.pathname + '?' + window.location.href.split('?')[1]) } else {

How to set up Google Analytics through Google Tag Manager for Next-Js?

左心房为你撑大大i 提交于 2021-02-18 05:04:53
问题 formerly I was using react-ga npm module to insert google analytics in my next js app. and It was simply like this: import ReactGA from 'react-ga' export const initGA = () => { ReactGA.initialize('UA-*******-*', { titleCase: false }) } export const logPageView = () => { if (window.location.href.split('?')[1]) { ReactGA.set({page: window.location.pathname + '?' + window.location.href.split('?')[1]}) ReactGA.pageview(window.location.pathname + '?' + window.location.href.split('?')[1]) } else {

Google Tag Manager - Primary Expression Expected

不羁岁月 提交于 2021-02-11 14:14:27
问题 Following is my code: <script> <button type = "button" onclick="sce.event('mw_button_click', { ...});> </button> </script> And when i try to enter the debug mode in Google Tag Manager I have an error: Error in line 2 character 4: Pare error. Primary expression expected. Does anyone know how to fix it and can help me? 回答1: If you use the button tag inside the script tag it doesn't work in GTM .Instead you should use Javascript or Jquery like I mentioned below The below is an example from https

Reporting URL of downloads in Data Studio when using Google Analytics 4 automatic enhanced measurement events?

こ雲淡風輕ζ 提交于 2021-02-08 23:36:54
问题 I have setup a new Google Analytics 4 property and have enabled enhanced tracking, which records all downloads automatically. When using Google Data Studio, I can see 'file_download' events (so it's definitely working) and use this data to build my report. I need to create a report that shows which files were downloaded each month for a specific page only. It's really easy to get the total number of downloads which occurred on that page, however, I can't for the life of me find any way to

How to use Google Tag Manager with Multiple Schema Product reviews using JSON-LD and Variables

可紊 提交于 2021-02-08 20:52:49
问题 So I'm using Google Tag Manager to add Schema JSON-LD Product reviews to some pages and I'm stuck and unable to find any resources on the issue. The issue that I'm having is how can I tell GTM there are multiple elements and they should be repeated in JSON-LD each with their unique values. The method I'm using to get the values is using CSS selectors which are not unique because on some pages they can appear 20 times and on others 30 times. The variables are obtained by Google GTM. Using

How to use Google Tag Manager with Multiple Schema Product reviews using JSON-LD and Variables

荒凉一梦 提交于 2021-02-08 20:51:09
问题 So I'm using Google Tag Manager to add Schema JSON-LD Product reviews to some pages and I'm stuck and unable to find any resources on the issue. The issue that I'm having is how can I tell GTM there are multiple elements and they should be repeated in JSON-LD each with their unique values. The method I'm using to get the values is using CSS selectors which are not unique because on some pages they can appear 20 times and on others 30 times. The variables are obtained by Google GTM. Using

Run Google Tag Manager script inside of a separate JavaScript file?

与世无争的帅哥 提交于 2021-01-29 13:12:40
问题 I wish to put the Google Tag Manager code that should be placed in the <head> of the .html page, in a separate JavaScript file. Something along the lines of this: <script src="/js/tagmanager.js"></script> The code that should be placed in the head, provided by google: <!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async

Google Tag Manager - Parse Dynamic Data Layer Variable

感情迁移 提交于 2021-01-29 08:38:59
问题 I want to parse a 'pushed' data layer string. I intend to use it to track click events and setup the appropiate funnels in Google Analytics, it looks as follows: products.view.19|view recent product|19 The first part (products.view.19) is the unique page identifier. The second part (view recent product) is the action. The last part is (19) is the action identifier, this way actions may be grouped and compared more easily. So I did the following, I first created a trigger (it fires when a link

Google Tag Manager JavaScript Error trigger not fired before gtm load

人走茶凉 提交于 2021-01-29 08:08:07
问题 I added a JavaScript Error trigger in GTM, and obviously it won't fired in the page before gtm loads. I wonder how can I catch those errors, e.g. I have below script before gtm loads <script> undefinedObject.undefinedMethod(); </script> // I can see error in browser console but GTM because this error occurs before GTM loads. I tried to overwrite window.onerror function at the very beginning with pushing error event to dataLayer window.dataLayer = window.dataLayer || []; window.onerror =