GTM - JS Variable - Analytics Client ID

    0

    0

    Wesley van Wyk

    The code returns the client ID of the first element in the ga.getAll() array.

    function(){
      return ga.getAll()[0].get('clientId');
    }
    
    function() {
      try {
        var tracker = ga.getAll()[0];
        return tracker.get('clientId');
      } catch(e) {
        console.log("Error fetching clientId");
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.