How do I exclude builder.io preview/live page traffic from Google Analytics?

To disable Analytics programmatically, set the following window property to true:

window['ga-disable-GA_MEASUREMENT_ID'] = true;

Replace GA_MEASUREMENT_ID with the Analytics ID of the property that you would like to disable.

<script>
// INSERT THIS AT THE TOP OF THE SCRIPT TAG
function exclude_ga(){
  var urlParts = new URL(window.location.href);
  if(urlParts.searchParams.get('__builder_editing__')){
     window['ga-disable-GA_MEASUREMENT_ID'] = true;         
     window['ga-disable-GA_PROPERTY_ID'] = true;
  }
}
// CALL THE EXCLUDE FUNCTION
exclude_ga();
</script>