google-analytics-element icon indicating copy to clipboard operation
google-analytics-element copied to clipboard

Web Component wrapper for Google Analytics code using Polymer

<google-analytics>

Web Component wrapper for Google Analytics code using Polymer.

Maintained by Cesar William.

Test on Google Analytics

Installation

Using Bower:

  1. Run this command from your project root:

    bower install google-analytics --save
    
  2. Import Web Components' polyfill:

    <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
    
  3. Import the component by adding this to your HTML file:

    <link rel="import" href="bower_components/google-analytics/google-analytics.html">
    
  4. Start using it!

    <google-analytics code="UA-XXXXX-Y"></google-analytics>
    

Options

Attribute Options Default Description
code string UA-XXXXX-Y Your Google Analytics tracking code
displayfeatures boolean false Optional. Define the display features option
pages array [] Optional. The path portion of the page URL. Should begin with '/' like this '["/sample1", "/sample2"]'

See Google Analytics official documentation.

History

For detailed changelog, check Releases.

License

MIT License