Node.js example not working
See original GitHub issueHi, this seems like a great library and it is exactly what I need for my project. However, I can’t get it to work in my node.js application. Even the basic example from the documentation is not working for me:
const analyticsLib = require('analytics').default
const googleAnalytics = require('@analytics/google-analytics').default
const analytics = analyticsLib({
app: 'my-app-name',
plugins: [
googleAnalytics({
trackingId: '123-xyz'
})
]
})
/* Track a page view */
analytics.page()
Using analytics.page() throws an error (Error: Missing path, href or title in page call for GA). If I do the following:
analytics.page({
title: 'test',
href: 'http://localhost:3000',
path: '/'
})
the code runs, but I don’t see any page event in Google Analytics. And of course, I replaced the trackingId from the sample code with my own.
Any hints that can help me to get page views tracked?
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
6 reasons your Node.js apps are failing - IBM Developer
6 reasons your Node.js apps are failing · 1. Uncaught exceptions or error events in JavaScript code · 2. Excessive memory usage, which...
Read more >Node.js Hello World not working - Stack Overflow
I'm trying to get my node.js Hello World code to work. My problem is that when I try to run my "Hello World"...
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
Mistake #5: Assigning to “exports”, Instead of “module. exports” Node. js treats each file as a small isolated module.
Read more >Errors | Node.js v19.3.0 Documentation
Node.js generates system errors when exceptions occur within its runtime environment. These usually occur when an application violates an operating system ...
Read more >Node.js Error: Cannot GET/ from running the url on the web ...
Problem Statement: On running a Node. · Example: Let's create a simple Node. · Step 1: Initializes NPM: · Step 2: Install Dependencies:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A few tings:
Enable debug: true just under “app” - If you are seeing that https://getanalytics.io/debugging/ is giving you the page() hit then the analytics module is working and you’re trying to do something non-standard
Have you installed the relevant packages? You’ll need
Yep those are required from the underlying lib https://github.com/DavidWells/analytics/blob/master/packages/analytics-plugin-google-analytics/src/node.js#L59