How can I run a Google Analytic’s snippet from a .js file that contains no HTML? With no HTML present I receive the console error:
Uncaught TypeError: Cannot read property 'parentNode' of undefined
CLARIFICATION
Sorry this was a very unclear question. I had created a Chrome Extension that does not have an actual page but rather injects a script to be run on a declared webpage. I wanted Google Analytic’s to keep count of how many time the script was used. My Solution is provided below.
The problem is there is no page element because the script is being injected.
Here is the fix: