Closed that70schris closed 3 years ago
thanks for posting @that70schris
one approach I realized you should be able to take for Angular -
// <builder-component (load)="onLoad($event)" ...>...</builder-component>
onLoad(content) {
const id = content.id;
// Wait for the cookie to be set
setTimeout(() => {
// Substitute your own cookie reading library/implementation for `readCookie`
const testId = readCookie(`builder.tests.${id}`);
if (testId === id) {
track('someEvent', { testVariationId: testId, name: content.name })
} else {
const testVariationInfo = content.variations[testId];
track('someEvent', { testVariationId: testId, name: testVariationInfo.name })
}
})
}
content doesn't seem to have a variations
field
ah just took a look at the code and I believe we actually preprocess to find the right match and what you actually just want are the name
(which is the test variation name) and id
(which is the test variation id) fields - can you give that a try and see if behaving as expected?
so really just this then?
this.track.impression({
type: 'builder',
testVariationId: content.id,
testVariationName: content.name,
});
I believe so, but you'll want to check and make sure for the same content (e.g. a 50/50 test) you are getting different id/names to ensure I'm correct here
doesn't look like this is the case, it's reporting the same id/name after 8 page views
just to confirm - the tests are sticky with a cookie, did you make sure to test in new incognito browsers (with no other incognito windows open) each time?
nvm confirmed my original suspicion is correct. the way we send HTML to angular the test group is not yet known and sending the full test variations object is omited for performance reasons
if it works for you, you'll want to do the cookie method described above, you just won't know the test variation name, but you will have the ID
// <builder-component (load)="onLoad($event)" ...>...</builder-component>
onLoad(content) {
const id = content.id;
// Wait for the cookie to be set
setTimeout(() => {
// Substitute your own cookie reading library/implementation for `readCookie`
const testId = readCookie(`builder.tests.${id}`);
if (testId === id) {
track('someEvent', { testVariationId: testId })
} else {
track('someEvent', { testVariationId: testId })
}
})
}
the problem is content.variations
does not exist
correct, you'll see it is not in that code above, you don't need it to know the variation ID
oh you have const testVariationInfo = content.variations[testId]
but you're not using it, got it
ah woops missed that :D
we're all set thanks!
tried to follow this:
https://forum.builder.io/t/tracking-builder-data-to-other-analytics-providers/160
but the fields specified in the post are not available on Angular's
$event
object passed back in theload
event: