End Goal: I want to create a Chrome Extension using which I can execute basic Web Analytics commands for different tools by configuring few buttons in extensions.
Issue: I am able to create a basic extension and get alert generated on click of a button as a test. Now I am aiming to execute commands involving Tealium or Adobe Launch or Evidon and output the results through an alert. But I am seeing absence of .js file as error.
Example Scenario: If my website contains Tealium Tag Manager, then I can execute utag.cfg.v on chrome console command and get latest Tealium version as a string like "2022.07.04.5625". I want to store output of this command into a variable and execute it on click of chrome extension button. When I run code in console, it works fine but running it through extension does nothing! I can see error as "utag is not defined". Sample code below.
popup.js
document.addEventListener('DOMContentLoaded', function() {
var checkButton = document.getElementById('check');
checkButton.addEventListener('click', function()
{
var test = utag.cfg.v;
//var test = "Hello!"
alert("Test Output:" + test);
}, false);
}, false);
popup.html
<html>
<head>
<title>Test of Times!</title>
<script src="popup.js"></script>
</head>
<body>
<h1>Web Analytics</h1>
<h3 class="sub-heading">Chrome extension for Web Analytics.</h3>
<button id="check">Test Me</button>
</body>
</html>
Any help will is much appreciated and I am not very well versed in JavaScript so please feel free to point out details even if it's very obvious.
Thanks!