Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics on homepage? #80

Open
j-f1 opened this issue Feb 20, 2018 · 1 comment
Open

Analytics on homepage? #80

j-f1 opened this issue Feb 20, 2018 · 1 comment

Comments

@j-f1
Copy link

j-f1 commented Feb 20, 2018

Attempting to GET the / endpoint yields Please include a path to a page. on the client and:

Error: Please include a path to a page.
    at createError (/app/node_modules/micro/lib/server.js:152:15)
    at analyticsHandler (/app/node_modules/micro-analytics-cli/src/handler.js:58:11)
    at /app/node_modules/micro-analytics-cli/src/handler.js:109:16
    at resolve (/app/node_modules/micro/lib/server.js:24:34)
    at Promise._execute (/app/node_modules/bluebird/js/release/debuggability.js:300:9)
    at Promise._resolveFromExecutor (/app/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/app/node_modules/bluebird/js/release/promise.js:79:10)
    at Function.exports.run (/app/node_modules/micro/lib/server.js:24:3)
    at Server.server (/app/node_modules/micro/lib/server.js:13:50)
    at emitTwo (events.js:126:13)
    at Server.emit (events.js:214:7)
    at parserOnIncoming (_http_server.js:602:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)

in the server logs. Is there any way to track events at the root page?

For example, running fetch(`https://my-micro.analytics/${location.pathname}`) doesn’t record visits to the homepage.

@saulhardman
Copy link

Hey @j-f1, I'm using a single MicroAnalytics instance to track all of my sites. I prefix the path with a 'namespace', like so:-

fetch(`https://my-micro.analytics/my-website.com${location.pathname}`)
// => https://my-micro.analytics/my-website.com/this-is-the-path/

I know adding a generic namespace like 'website' might no be ideal, but it works in this case. Tip: test using ?inc=false initially to ensure that the string template/concatenation is working as expected before entries are added – getting the slashes right can be a bit of a pain at times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants