mirror of
https://github.com/google/material-design-lite.git
synced 2024-09-11 12:25:38 +03:00
Track clicks to the components page as pageviews.
Also track correctly a direct page load to a component.
This commit is contained in:
parent
11ced2560b
commit
cf87a03942
@ -130,10 +130,15 @@ MaterialComponentsNav.prototype.clickHandler = function(link) {
|
||||
|
||||
// Add an history entry and display the hash fragment in the URL.
|
||||
var section = window.location.hash.split('/')[0];
|
||||
if (section !== '#' + link.href.split('#')[1]) {
|
||||
var linkWithoutHash = link.href.split('#')[1];
|
||||
if (section !== '#' + linkWithoutHash) {
|
||||
history.pushState(null, 'Material Design Lite', link);
|
||||
// Scroll to top of page
|
||||
document.getElementById('content').scrollTop = 0;
|
||||
// Track the specific component page view in Google analytics
|
||||
if (ga) {
|
||||
ga('send', 'pageview', '/components/' + linkWithoutHash);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}.bind(this);
|
||||
|
10
docs/_templates/layout.html
vendored
10
docs/_templates/layout.html
vendored
@ -53,7 +53,15 @@
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-25993200-9', 'auto');
|
||||
ga('send', 'pageview');
|
||||
// If a specific component page is loaded directly we'll attribute the
|
||||
// page view to the specific component's page
|
||||
if (window.location.pathname.indexOf('/components/') !== -1 &&
|
||||
window.location.hash.indexOf('-section') !== -1) {
|
||||
ga('send', 'pageview', '/components/' +
|
||||
window.location.hash.split('#')[1].split('/')[0]);
|
||||
} else {
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
// }
|
||||
|
||||
// Setup error tracking before anything else runs.
|
||||
|
Loading…
Reference in New Issue
Block a user