Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
docpad-plugin-analytics
Advanced tools
Retrieves google analytics data from your analytics account so it can be displayed within a docpad application
Retrieves Google Analytics data using serverside authentication via the embed api. Google returns analytic data in the form of a JSON object which can be used to produce tables, charts and reports. The plugin does not create these reports - just retrieves the data (which is really the hard part). Once you have the data it is simple enough to use something like Chart.js to create nice visual charts. The charts example shows how to do this. The data returned from the plugin is an abbreviated version of that returned from google.
{
"totalResults": 20,
"columnHeaders": [
{
"name": "ga:pagePath",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "ga:uniquePageviews",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"totalsForAllResults": {
"ga:uniquePageviews": "27845"
},
"rows": [
[
"/",
"6500"
],
[
"/news",
"21345"
]
]
}
The advantage of this approach that you don't need to give users access to your analytics account and the users don't need to log in to google to access the data. This makes a lot more sense for an admin style page that shows analytic data. Of course, you will probably want to protect this admin page with some sort of login for the website. So you will probably want to use this plugin in conjunction with an authentication plugin such as docpad-plugin-authentication.
The plugin relies on downloading from Google what they call a "JSON key". This is a json file containing all the necessary credentials for making calls to the embed API. All details can be found at: https://ga-dev-tools.appspot.com/embed-api/server-side-authorization/
Once you have the "JSON key" you need to place it in the root of your DocPad application. The plugin will load it from there. By default the plugin expects it to be named "credentials.json".
In docpad.coffee file configure the google analytics id for your site.
plugins:
analytics:
qryId: 'ga:123456789'
Each analytics query is identified by an endPoint
. The endPoint
parameter is appended to the base dataURL, by default, /analytics/data
. So to retrieve the uniquePageviews
query your application needs to make a call to /analytics/data/uniquePageviews
.
$.getJSON('/analytics/data/uniquePageviews',function(data){
$('#results pre').html(JSON.stringify(data,null,4));
});
The endpoints for the default, built in queries are:
'metrics': 'ga:uniquePageviews'
'dimensions': 'ga:pageTitle'
'start-date': '30daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:uniquePageviews'
'dimensions': 'ga:pageTitle'
'start-date': '7daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:uniquePageviews'
'dimensions': 'ga:pageTitle'
'start-date': 'yesterday'
'end-date': 'yesterday'
'metrics': 'ga:sessions'
'dimensions': 'ga:date'
'start-date': '60daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:sessions'
'dimensions': 'ga:country,ga:countryIsoCode'
'start-date': '30daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:sessions'
'dimensions': 'ga:country,ga:countryIsoCode'
'start-date': '7daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:sessions'
'dimensions': 'ga:country,ga:countryIsoCode'
'start-date': 'yesterday'
'end-date': 'yesterday'
'metrics': 'ga:sessions'
'dimensions': 'ga:browser,ga:browserVersion,ga:operatingSystem,ga:operatingSystemVersion'
'start-date': '30daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:sessions,ga:sessionDuration'
'start-date': '30daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:sessions,ga:pageviews,ga:sessionDuration,ga:exits'
'dimensions': 'ga:source,ga:medium'
'start-date': '30daysAgo'
'end-date': 'yesterday'
'metrics': 'ga:sessions'
'dimensions': 'ga:keyword'
'start-date': '30daysAgo'
'end-date': 'yesterday'
To build and test queries use google's query explorer
FAQs
Retrieves google analytics data from your analytics account so it can be displayed within a docpad application
The npm package docpad-plugin-analytics receives a total of 0 weekly downloads. As such, docpad-plugin-analytics popularity was classified as not popular.
We found that docpad-plugin-analytics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.