0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

reactにmatomoを設置する

Posted at

一応これは、reactのApp.jsで、htmlは別ファイルでTopPageから読み込んいる場合で、
Matomoはphpのローカルホストで起動しているケースを想定しています。

Matomoのタグマネージャーを使って、こちらのページを参考に設定したタグを貼り付けます。

App.js
import { useEffect } from "react";
import TopPage from "./pages/TopPage";
import "./App.css";

function App() {
  useEffect(() => {
    var _mtm = (window._mtm = window._mtm || []);
    _mtm.push({ "mtm.startTime": new Date().getTime(), event: "mtm.Start" });
    (function () {
      var d = document,
        g = d.createElement("script"),
        s = d.getElementsByTagName("script")[0];
      g.async = true;
      g.src = "http://localhost:8080/js/container_lgZFFjJ9.js";
      s.parentNode.insertBefore(g, s);
    })();
  });
  
  return (
    <div className="App">
      <TopPage />
    </div>
  );
}

export default App;

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?