Skip to content

Instantly share code, notes, and snippets.

@malchak
Last active August 15, 2019 18:21
Show Gist options
  • Save malchak/5bb94f034715b8cff73a5ee73bbceceb to your computer and use it in GitHub Desktop.
Save malchak/5bb94f034715b8cff73a5ee73bbceceb to your computer and use it in GitHub Desktop.
Anonymous Id Issue (analytics.js)

Segment script called on analytics.ready()

<script type="text/javascript">
  analytics.ready(function() {
    analytics.user().anonymousId('80242030-bf79-11e9-a17a-07af333ee672');    
  });
</script>

Payload assigned in the first identify call sent to segment

{
	"integrations": {},
	"context": {
		"page": {
			"path": "/",
			"referrer": "",
			"search": "",
			"title": "SURFLINE.COM | Global Surf Reports, Surf Forecasts, Live Surf Cams and Coastal Weather",
			"url": "https://www.surfline.com/"
		},
		"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
		"library": {
			"name": "analytics.js",
			"version": "3.9.0"
		}
	},
	"traits": {
		"crossDomainId": "41a1c8f6-3f05-4664-99ea-f83ade351826"
	},
	"userId": null,
	"messageId": "ajs-1927dbe0bfa3380e80647d673440ba63",
	"anonymousId": "4abe8c58-3c84-404b-8f56-f4c259f610ed",
	"timestamp": "2019-08-15T16:27:08.353Z",
	"type": "identify",
	"writeKey": "<removed from gist>",
	"sentAt": "2019-08-15T16:27:08.365Z",
	"_metadata": {
		"bundled": ["AdRoll", "Facebook Pixel", "Google Analytics", "Segment.io", "Wootric"],
		"unbundled": ["Customer.io"]
	}
}

We see that the anonymousId (UUID) in the indentify call is different from the UUID we've generated and assigned to the user.

On ready: '80242030-bf79-11e9-a17a-07af333ee672'

On indentify: '4abe8c58-3c84-404b-8f56-f4c259f610ed'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment