1.0.2 • Published 3 years ago

grapesjs-ga v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Grapesjs Google Analytics

Easily link to your google analytics or google tag manager

DEMO

HTML

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/grapesjs-ga"></script>

<div id="gjs"></div>

JS

const editor = grapesjs.init({
	container: '#gjs',
  height: '100%',
  fromElement: true,
  storageManager: false,
  plugins: ['grapesjs-ga'],
});

CSS

body, html {
  margin: 0;
  height: 100%;
}

Summary

  • Plugin name: grapesjs-ga
  • Components
    • gtm
    • ga
  • Blocks
    • gtm-block
    • ga-block

Options

OptionDescriptionDefault
gtmIdvalue from google tag manager dashboard
gtmLabellabel for google tag manager blockTag Manager
gtmCategorycategory for google tag manager blockGoogle
gtmBlockoptions to extend google tag manager block{}
gtmComponentoptions to extend google tag manager component model{}
gaIdvalue from google analytics dashboard
gaLabellabel for google analytics blockAnalytics
gaCategorycategory for google analytics blockGoogle
gaBlockoptions to extend google analytics block{}
gaComponentoptions to extend google analytics component model{}

Download

  • CDN
    • https://unpkg.com/grapesjs-ga
  • NPM
    • npm i grapesjs-ga
  • GIT
    • git clone https://github.com/ju99ernaut/grapesjs-ga.git

Usage

Directly in the browser

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="path/to/grapesjs-ga.min.js"></script>

<div id="gjs"></div>

<script type="text/javascript">
  var editor = grapesjs.init({
      container: '#gjs',
      // ...
      plugins: ['grapesjs-ga'],
      pluginsOpts: {
        'grapesjs-ga': { /* options */ }
      }
  });
</script>

Modern javascript

import grapesjs from 'grapesjs';
import plugin from 'grapesjs-ga';
import 'grapesjs/dist/css/grapes.min.css';

const editor = grapesjs.init({
  container : '#gjs',
  // ...
  plugins: [plugin],
  pluginsOpts: {
    [plugin]: { /* options */ }
  }
  // or
  plugins: [
    editor => plugin(editor, { /* options */ }),
  ],
});

Development

Clone the repository

$ git clone https://github.com/ju99ernaut/grapesjs-ga.git
$ cd grapesjs-ga

Install dependencies

$ npm i

Start the dev server

$ npm start

Build the source

$ npm run build

License

MIT