0

当我从一个页面导航到另一个页面时,我需要加载我的谷歌标签管理器。但目前只有当我重新加载页面时才会发生,否则不会。我正在使用反应静态项目。示例链接:https ://github.com/PrasanthGokuldas/Test_ReactStatic/tree/master/src

应用程序.js

import React, { Component, useEffect } from 'react'
import { Root, Routes } from 'react-static'
import { Link, Router } from 'components/Router'
// import Header from './pages/common/header';
import Menubar from './pages/common/menubar';
import Footer from './pages/common/footer';
import LoadingProcess from './pages/common/loading-process';
import './pages/sass/app.scss';

import 'bootstrap/dist/css/bootstrap.min.css';
import TagManager from 'react-gtm-module';

class App extends Component {
componentDidMount() {
**const tagManagerArgs = {
gtmId: 'GTM-T7FPMNs'
}
TagManager.initialize(tagManagerArgs);**
}
render() {

return (
  <Root>
    <React.Suspense fallback={<LoadingProcess />}>
      <div className="app-top-container">
        <Menubar />
        <div className="content app-container">
          <Router>
            <Routes path="*" />
          </Router>
        </div>
        <Footer />
      </div>
    </React.Suspense>
  </Root>
)
}
}

export default App
4

0 回答 0