Programmatically add customer event

I can manually add customer event code to handle events like “checkout_completed” and programmatically add scripts but I cannot figure out how to programmatically add customer event pixel when my app is installed.

Is there a way I can add code and subscribe to analytics upon installing my app so clients don’t have to manually add custom customer event pixel code?