For example, you could use them to track certain specific metrics that are not included as default options in the metrics builder, like scroll depth or cart abandonment.
Custom code is used at the variation level;
Shared code is used at the experiment level;
You want to track unique custom events, such as scroll depth and mouse hover.
You want to add API calls for custom metrics.
You want to run experiments on single-page apps that execute without requiring the user to reload the page.
You want to reuse custom modules, like lightboxes or banners, across multiple experiments. Here, you should use editor extensions instead.
You want to manage multiple analytics integrations on the same page. Optimizely’s analytics extensions accomplish this goal more efficiently than writing your own code from scratch.