'Google Analytics works for one UA and not another

I am using Nodejs and am trying to test logging events using Google Analytics. The two UAs are divided into a development site and an operational site, both with different URLs so, development site A has UA A and operational site B has UA B. A works just fine and I can see the realtime events but site B does not. The code did not change just the UA and domain. I'm not sure why B will not show any hits and could use a bit of help.

Heres the route code:

const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
var express = require('express');
var router = express.Router();
var validator = require('validator');
var hdfctrl = require('../controllers/hdfController');

async function gaCollect(req, debug = false) {
  const GA_TRACKING_ID = "UA-XXXXXXX";
  bodyjson = {v: "1", tid: GA_TRACKING_ID, cid: "555", t: "event", ds: "alucard web services"};
  if (typeof req.query.list !== 'undefined') {
    bodyjson.ec = 'list';
    bodyjson.ea = 'get';
    bodyjson.el = validator.escape(req.query.list);
  }
  else if (typeof req.query.active !== 'undefined') {
    bodyjson.ec = 'active';
    bodyjson.ea = 'get';
    bodyjson.el = validator.escape(req.query.active);
  }
  else {
    bodyjson.ea = 'get';
    bodyjson.ec = validator.escape(req.query.productid);
    bodyjson.el = validator.escape(req.query.name);
    bodyjson.ev = validator.escape(req.query.begin) + validator.escape(req.query.end);
  }
  
  var url = 'https://www.google-analytics.com/collect' 
  if (debug)  {
    url = 'https://www.google-analytics.com/debug/collect';
  }

  var res = await fetch(url,{method:'POST',body:new URLSearchParams(bodyjson).toString(),headers: {'Content-Type': 'application/json'}});
  
  if (debug) {
    var data = await res.json();
    console.log(data.hitParsingResult[0])
  }
}

router.get('/productdata', function(req, res, next) {
  res.render('index', { title: 'data' });
});

router.get('/productdata/get', function(req, res, next) {
  gaCollect(req);
  hdfctrl.get(req, res, next);
});

module.exports = router;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source