googleanalytics@1.0.0

googleanalytics@1.0.0

Generate blocks with all Google Analytics tracking scripts.

By @mantradev

Install with:

$ mantrad download-component googleanalytics@1.0.0

Or install last version with:

$ mantrad download-component googleanalytics

README.md

googleanalytics Mantra component

This component creates three blocks to be inserted in html content to add Google Analytics 4 IDs ("ga" and "tag" ids).

Blocks generated by googleanalytics component

googleanalytics-tagsnippet block

This is the block that should be inserted in head section of the html content to include Google Analytics tag tracking.

googleanalytics-tagsnippet-body block

This is the block that should be inserted in the body section of the html content to include Google Analytics tag tracking.

googleanalytics-gasnippet block

This is the block needed by Google Analytics to follow audiences.

Sample

Here there is an index.html sample with the two blocks added:

<!DOCTYPE html>
<html lang="en">
  <head>
    {{{googleanalytics-gasnippet}}}
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    {{{mantra-css-files}}}
  </head>

  <body>
    {{{googleanalytics-gasnippet-body}}}
    
    <main class="main-content">
      <div class="container mt-8 mb-4">
        {{{mantra-content-view}}}
      </div>
    </main>

    {{{mantra-js-files}}}
    {{{googleanalytics-gasnippet}}}
  </body>
</html>

googleanalytics configuration

The component defines two configuration values named "tagid" and "gaid" that you should override in mantraconfig.json configuration file. You should get those ids from Google Analytics administration console.

"googleanalytics": {
    "tagid": "<your tag id>",
    "gaid": "<your ga id>"
}