Hello,
I’m trying to track all the GA events, using the node.js tracker which I have implemented in the GCP cloud function.
- Initially for testing I use snowplow mini for this, where the URL http://MINI_URL//iglu-server/api/schemas does not have any schema set.
- By logging in the snowplow mini, I could find webapp called Swagger an IGLU server API where we can set, get and post any custom or self describing SCHEMA.
Here is my tracking code:
/**
* Responds to any HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
// const snowplow = require('@snowplow/node-tracker');
import snowplow from "@snowplow/node-tracker"
var gotEmitter = snowplow.gotEmitter;
var tracker = snowplow.tracker;
var buildPageView = snowplow.buildPageView;
var buildStructEvent = snowplow.buildStructEvent;
var buildSelfDescribingEvent = snowplow.buildSelfDescribingEvent;
const e = gotEmitter(
'com.snowplow-mini-url', // Endpoint
snowplow.HttpProtocol.HTTPS, // Protocol
443, // Port
snowplow.HttpMethod.POST, // Method
1, // Buffer Size
5, // Retries
undefined,
function (error, response) { // Callback called for each request
if (error) {
console.log(error, 'Request error');
rej(error)
} else {
console.log('Event Sent'.response.statusCode);
res(response)
}
},
)
const t = tracker([e], 'myTracker', 'myApp', false);
t.setUserId('alexd');
t.setPlatform('platform');
t.setDomainUserId('domainUserId');
t.setNetworkUserId('userID');
t.setLang('en');
t.setScreenResolution(375, 812);;
t.setColorDepth(24);
t.setTimezone('Asia/Kuala_Lumpur');
export const ss_test = (request,response) => {
t.track(buildStructEvent({
category: "shop",
action: "add-to-basket",
label: "product",
property: "pcs",
value: 2
}));
t.track(buildSelfDescribingEvent({
event: {
schema: "iglu:com.snowplow..self-desc/schema/jsonschema/1-0-0",
data: {
save_id: "4321",
level: 23,
difficultyLevel: "HARD",
dl_content: true
}
}
}));
t.track(buildPageView({
pageUrl: 'http://www.example.com',
referrer: 'http://www.referer.com'
}),
[{
"schema": "iglu:com.acme_company/example/jsonschema/2-1-1",
"data": {
"data": "foo",
"date": "2022-01-01"
}
}]);
response.send()
};
I got stuck in here, whether to track GA events I have to change the tracker code or just to set the schema in IGLU server API or is there is any other ways to do that ?