Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

Swup GA plugin

Google Analytics plugin triggers pageview event on contentReplaced (on each page change). Note that this event is not triggered at the first load, so the first page view must be triggered elsewhere. However, page view event is by default triggered in Javascripts tracking snippet used for embedding GA. Simplified code run by this plugin on contentReplaced event:

window.ga('set', 'title', document.title);
window.ga('set', 'page', window.location.pathname + window.location.search);
window.ga('send', 'pageview');

Instalation

This plugin can be installed with npm

npm install @swup/ga-plugin

and included with import

import SwupGaPlugin from '@swup/ga-plugin';

or included from the dist folder

<script src="./dist/SwupGaPlugin.js"></script>

Usage

To run this plugin, include an instance in the swup options.

const swup = new Swup({
  plugins: [new SwupGaPlugin()]
});
You can’t perform that action at this time.