For analysing data context is very important. How about check how battery level influence for web user behaviour?
To solve this case I’ve prepared modification of code. This code put battery level in dataLayer and you can track it in every web analytics solution using Google Tag Manager.
Create Custom HTML tag with this code:
Publish your container and that’s it!
Now create new dataLayer variables in GTM to get this values and send i.e. in Google Analytics tracking as custom dimension (session scope):
Check also source code on my Github.