Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Add html's src inside JavaScript

I have an HTML code that has only one line of code:

<script async src="https://www.googletagmanager.com/gtag/js?id=ID"></script>

But I do not want to use HTML at all. Since I am performing all my functions inside my javascript, can I add the above code inside my JavaScript? If so, how?

  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'ID');
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To answer my own rhetorical question, there is a way to append url inside my javascript by this way:

function appendScript(){
    var script = document.createElement("script");
    script.src = "https://www.googletagmanager.com/gtag/js?id=ID"; 
    document.head.appendChild(script);
}

appendScript();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!