0

Server-side sending GA Measurement Protocol Parameters

Hello 👋

I'm using Segment server-side. How can i send these parameters to Google Analytics?

For example i've tried to send screen size in two different ways without success:

{
  "integrations": {
    "Google Analytics": {
      "clientId": "***",
      "sr": "2560x1440",
    }
  },
  "properties": {
    "title": "Pagename",
    "url": "http://www.example.com"
  },
  "type": "page",
  "userId": "***",
  "writeKey": "***"
}

And

{
  "context": {
    "screen": {
      "height": 222,
      "width": 777
    },
  },
  "integrations": {
    "Google Analytics": {
      "clientId": "***",
    }
  },
  "properties": {
    "title": "Pagename",
    "url": "http://www.example.com"
  },
  "type": "page",
  "userId": "***",
  "writeKey": "***"
}
1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi Nick - happy yo help 👋

    I ran a test, and I was able to pass screen size, here's my payload:  

    Segment Event Payload:

    {
      "context": {
          "screen": {
          "height": "222",
          "width": "777"
        },
        "page": {
          "path": "/index.html",
          "referrer": "https://www.google.com/",
          "search": "",
          "title": "Home Questionnaire",
          "url": "https://www.google.com/"
        },
        "userAgent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Mobile Safari/537.36"
      },
      "receivedAt": "2019-03-07T14:39:23.403Z",
      "sentAt": "2019-03-07T14:39:23.309Z",
      "timestamp": "2019-03-07T14:39:23.392Z",
      "type": "page",
      "userId": "1234"
    }
    

    Sent to Google Analytics ("sr": "1440x2560"): 

    {
      "body": {
        "cid": 123,
        "dh": "www.google.com",
        "dp": "/",
        "dr": "https://www.google.com/",
        "qt": 143,
        "sr": "777x222",
        "t": "pageview",
        "tid": "UA-000",
        "ua": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Mobile Safari/537.36",
        "v": 1
      },
      "headers": {
        "Accept-Encoding": "identity",
        "Content-Type": "application/x-www-form-urlencoded",
        "User-Agent": "Segment.io/1.0"
      },
      "method": "POST",
      "qs": {},
      "url": "https://ssl.google-analytics.com/collect"
    }

    If you are still having issues let me know and I'm happy to create a support ticket for you.

    Priscila

    Reply Upvote