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

165
Views
Insert script tag in javascript

I used the following javascript function for our cookie consent message on our website. How can I add the Mailchimp code to this? The problem is that Mailchimp needs the <script id="mcjs">

Code I'm using to check if someone allows cookies. If so than activate Google Analytics etc.

function BlockCookie() {
var imported = document.createElement('script');
imported.src = 'https://www.googletagmanager.com/gtag/js?id=ANALYTICS_CODE';
document.head.appendChild(imported);

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

gtag('config', 'ANALYTICS_CODE', { 'anonymize_ip': true });

window._mfq = window._mfq || [];
  (function() {
    var mf = document.createElement(\"script\");
    mf.type = \"text/javascript\"; mf.defer = true;
    mf.src = \"//cdn.mouseflow.com/projects/cae0bb6e-2421-49b4.js\";
    document.getElementsByTagName(\"head\")[0].appendChild(mf);
  })();
}

Mailchimp code I would like to add to the function

<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h)[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}(document,"script","https://chimpstatic.com/mcjs-connected/js/users/01ad3420bde595/306da052f4.js");</script>
about 4 years ago · Juan Pablo Isaza
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!