title: How to track user journey in a single-page Flutter WEB app?
body: <p>I am new to google analytics, want to track the user's movement in my <strong>single-page</strong> <strong>Flutter</strong> app. The app consists of 6 pages using PageView. Specifically, I want to know how long a user stays on each page and their mouse click-events / movements. I tried this <a href="https://pub.dev/packages/google_tag_manager" rel="nofollow noreferrer">https://pub.dev/packages/google_tag_manager</a> but somehow no events are tracked in my analytics account (failed).</p>
  
  <p>Here is how I implemented</p>
  
  <pre><code>
  import 'package:google_tag_manager/google_tag_manager.dart' as gtm;
  
  class HomeView extends StatefulWidget {
  ...
  }
  
  class HomeViewState extends State&lt;HomeView&gt; with TickerProviderStateMixin  {
    ...
    Widget build(BuildContext context ) {
      homePageLanded();
      ...
    }
    void homePageLanded(){
      gtm.pushEvent('homeView-landed');
    }
  }
  </code></pre>
  
  <p>The code above is how I tried to log the event of users land on the Homeview. Similarily I did the same to the other views.</p>
  
  <p>This is the main structure of the site.</p>
  
  <pre><code>PageView(
      physics: physics,
      pageSnapping: true,
      scrollDirection: Axis.vertical,
      controller: _pageController,
      children: &lt;Widget&gt;[
          HomeView(utilities, _pageController),
          ViewTwo(utilities, _pageController),
          ViewThree(utilities, _pageController),
          ViewFour(utilities, _pageController),
          ViewFive(utilities, _pageController),
      ]
  ),
  </code></pre>
  
  <p>Are there any other steps required like setting up in Google Analytics?</p>
  
  <p>Thank you in advance!!</p>
  
  <p>--------------------UPDATE--------------------</p>
  
  <p>I am not quite sure the step 'deploying GTM', I have this script in head of index.html : </p>
  
  <pre><code>  &lt;script&gt;
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
  
    gtag('config', 'UA-162984477-1');
  
    &lt;script&gt;
    (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'?'&amp;l='+l:'';j.async=true;j.src=
    'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-5NHZTFT');
    &lt;/script&gt;
  </code></pre>