Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

Experience League LIVE: Post-session discussion - The basics of Web SDK

Avatar

Employee

Use this thread to ask any questions related to the Experience League LIVE session titled, "Ask the experts: The basics of Web SDK."

 

Experts are monitoring this thread to ensure your questions are answered. Thanks and we hope to hear from you!

1 Reply

Avatar

Employee Advisor

There was a request for the Javascript code that I'm using to set a GA Client ID. Keep in mind that I:

1. Haven't tested this with GA4 and so I don't know if a different identity format is expected. So check that if you are GA4'ing.

2. Am not a software engineer. So please don't make fun of my code

 

OKAY. With that out of the way, here's the Javascript I'm using in a client-side Adobe Tags data element in order to set a GA Client ID. I'm then passing that into an XDM field to my Web SDK event, and letting Event Forwarding send it off to GA3:

 

if(_satellite.cookie.get('gaclientid')==undefined)
{
  _satellite.logger.log('cookie not found');
  var part1 = Math.round(Math.random()*Math.pow(10,10));
  var part2 = Date.now();
  _satellite.cookie.set('gaclientid', part1+"."+part2);
  return part1+"."+part2;
}
else {
    _satellite.logger.log('cookie found');
  return _satellite.cookie.get('gaclientid');
}