joaoferreira / spfx-google-analytics Goto Github PK
View Code? Open in Web Editor NEWThis repository has a solution to add Google Analytics to the Modern SharePoint Sites
This repository has a solution to add Google Analytics to the Modern SharePoint Sites
Attempting to build the latest code but am getting a failure when trying to load the dependency for phantomjs which appears to be deprecated and no longer being supported. Any suggestions on what to replace this with?
Hi. I am using this solution. But We found out that Eval is not best practice. So we have tried below code for replacing Eval :
var gtmScript = document.createElement("script");
gtmScript.type = "text/javascript";
gtmScript.src = `https://www.googletagmanager.com/gtm.js?id=${trackingID}`;
gtmScript.async = true;
document.head.appendChild(gtmScript);
(window as any).dataLayer = (window as any).dataLayer || [];
(window as any).dataLayer.push(datalayerval);
(window as any).dataLayer.push({
'event': 'page-variables-NewDetails',
'sharepoint-user-id': userID,
'sharepoint-user-location': location,
'sharepoint-user-division': division,
'page-type': pageLayoutType,
'article-name': articleName,
'language': language,
'page-published': firstPublishedDate,
'web-title': this.context.pageContext.web.title,
'sharepoint-user-email': Email,
'sharepoint-user-first-name': firstName,
'sharepoint-user-last-name': LastName,
'sharepoint-user-mobile': mobile,
});
(window as any).dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
It is showing output in console. But the analytics is not able to catch it and the page count goes down when we deploy this. Can anyone tell how can we get rid of Eval?
I have clone this repository successfully. But When I try to upload sppkg package in app catalog, I am getting below issue:
In google-analytics.sppkg - Invalid SharePoint App package. Error: Part URI is not valid per rules defined in the Open Packaging Conventions specification.
Can you please look in to this?
Some of the navigation on modern pages happens so that the browser does not load the whole page again on page load. This causes some user navigation to not get tracked with this code.
Could you update the code so that it would also track when user navigates between different pages on the modern site? Now it tracks only the first load, maybe a bit depending which navigation element is clicked.
@joaoferreira - I have cloned this repository and then run below commands as suggested in guideline:
git clone the repo
npm i
npm i -g gulp
gulp
I am getting below error in gulp, gulp clean, gulp build, gulp serve.
Build target: DEBUG
C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\node-core-library\lib\JsonSchema.js:178
throw new Error(prefix + os.EOL +
^Error: JSON validation failed:
C:\Projects\SPFx-Google-Analytics-master\config\tslint.jsonError: #/ (Defines configuration options for the...)
Additional properties not allowed: lintConfig,useDefaultConfigAsBase,removeExistingRules,displayAsWarning
at validateObjectWithCallback (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\node-core-library\lib\JsonSchema.js:178:19)
at JsonSchema.validateObjectWithCallback (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\node-core-library\lib\JsonSchema.js:193:13)
at JsonSchema.validateObject (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\node-core-library\lib\JsonSchema.js:175:14)
at TslintCmdTask._readConfigFile (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\gulp-core-build\lib\tasks\GulpTask.js:311:28)
at TslintCmdTask.onRegister (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\gulp-core-build\lib\tasks\GulpTask.js:87:32)
at Object.initialize (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\gulp-core-build\lib\index.js:299:24)
at SPWebBuildRig.initialize (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\sp-build-common\lib\BuildRig.js:61:19)
at SPWebBuildRig.initialize (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\sp-build-common\lib\SPBuildRig.js:29:15)
at SPWebBuildRig.initialize (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\sp-build-web\lib\SPWebBuildRig.js:15:15)
at Object.exports.initialize (C:\Projects\SPFx-Google-Analytics-master\node_modules@microsoft\sp-build-web\lib\index.js:23:17)
below are my vm configuration:
gulp version
CLI version 2.1.0
Local version 3.9.1
npm version
6.8.0
node version
v8.12.0
Got json error after running gulp command
We have implemented GA on modern hub sites on Sharepoint online and noticed difference between GA and SP's reporting tool. One page we have 67 pageviews in GA and 894 views in SP. I think SP views are reported correctly, but GA is missing a huge part of the traffic. Please let me know what is missing/any settings required to be changed in GA?
Sharepoint extension has been created and Google Analytics code has been implemented same way in this post.
Any help would be much appreciated !!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.