Split test assignments
unknown
javascript
5 months ago
1.3 kB
6
Indexable
<script> (function() { // Ensure `window._uxa` is initialized window._uxa = window._uxa || []; // Function to push a single trackDynamicVariable entry to `window._uxa` function generateUxaTrackVariables(assignments) { for (var testId in assignments) { if (assignments.hasOwnProperty(testId)) { var assignment = assignments[testId]; // Ensure each assignment has both `test_id` and `test_group` properties if (assignment.test_id && assignment.test_group) { var test_id_value = assignment.test_id; var test_group_value = assignment.test_group; // Construct the dynamic key var key = "split_test_id_" + test_id_value; // Push a single `trackDynamicVariable` entry to `window._uxa` window._uxa.push(["trackDynamicVariable", { key: key, value: test_group_value }]); } } } } // Check if `split_test_assignments` exists and is an object if (typeof split_test_assignments === "object" && split_test_assignments !== null) { // Call the function with split test assignments data generateUxaTrackVariables(split_test_assignments); } })(); </script>
Editor is loading...
Leave a Comment