Skip to content

Commit ffc785e

Browse files
committed
Update for recent changes
1 parent 4f61e85 commit ffc785e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/index.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ export default class SwupGaPlugin extends Plugin {
1515
}
1616

1717
mount() {
18-
this.swup.hooks.on('page:view', this.trackPageView);
18+
this.on('page:view', this.trackPageView);
1919
}
2020

21-
unmount() {
22-
this.swup.hooks.off('page:view', this.trackPageView);
23-
}
24-
25-
trackPageView = () => {
21+
trackPageView() {
2622
const title = document.title;
2723
const url = window.location.pathname + window.location.search;
2824

@@ -37,7 +33,7 @@ export default class SwupGaPlugin extends Plugin {
3733
}
3834
}
3935

40-
trackPageViewInGtag = ({ title, url }) => {
36+
trackPageViewInGtag({ title, url }) {
4137
const { gaMeasurementId } = this.options;
4238
if (!gaMeasurementId) {
4339
console.error('The gaMeasurementId option is required for gtag.js');
@@ -50,7 +46,7 @@ export default class SwupGaPlugin extends Plugin {
5046
});
5147
}
5248

53-
trackPageViewInGa = ({ title, url }) => {
49+
trackPageViewInGa({ title, url }) {
5450
window.ga('set', 'title', title);
5551
window.ga('set', 'page', url);
5652
window.ga('send', 'pageview');

0 commit comments

Comments
 (0)