Code Monkey home page Code Monkey logo

Comments (3)

franckgavand avatar franckgavand commented on September 26, 2024 1

I have modified the script.js code to include the code in a window.onload function :
Looks like it solved the issue....
But I have no idea of possible side effects....

if (JSINFO.ga.gtagId) {
        /* Global site tag (gtag.js) - Google Analytics */
        window.onload=function(){
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = 'https://www.googletagmanager.com/gtag/js?id=' + JSINFO.ga.gtagId;
    
            //alert(document.body);
            //document.body.appendChild(script);
            document.body.appendChild(script);
    
    
            window.dataLayer = window.dataLayer || [];
    
            function gtag() {
                dataLayer.push(arguments);
            }
    
            gtag('js', new Date());
            gtag('config', JSINFO.ga.gtagId);
        }
    }

from dokuwiki-plugin-googleanalytics.

tatewake avatar tatewake commented on September 26, 2024

Hi @franckgavand , thank you. I'll take a look into this and add it in when I get some time.

from dokuwiki-plugin-googleanalytics.

jonyo avatar jonyo commented on September 26, 2024

By the way, I think you would only want to do that around the part adding the script tag so the rest runs without waiting for the page to load. Like, end it right after document.body.appendChild(script).

It was breaking JS on the page for me so I made this change by hand in the file for now and it seems to be working.

from dokuwiki-plugin-googleanalytics.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.