Skip to main content

Use OnePlan

Set Up Google Analytics with OnePlan

This article explains how to set up Google Analytics support to a OnePlan group to allow admins to track information about their OnePlan users.

Set Up Google Analytics

Follow the instructions in the article Set up Analytics for a website and/or app and/or app from Google.

  1. Follow all of the steps in Create an Analytics account.

  2. Follow all of the steps in Create a new Google Analytics 4 property.

  3. Follow the first two steps in Add a data stream. Then expand the Web section and follow the instructions.

  4. Under Set up data collection for websites, follow the instructions in the Find your "G-" ID (for any platform that accepts a "G-" ID) section. Copy your "G-" ID (Google Tag ID) and save it for use later in these instructions.

Configure OnePlan
  1. In OnePlan, click on the Settings gear to access the Config pages.

  2. Go to General > Advanced. Ensure the Enable Customizations checkbox is checked.

  3. Copy the following JavaScript script:

    var tag = 'YOUR_GOOGLE_TAG_ID_HERE';
    
    function addScript( src ) {    
    return new Promise( ( resolve, reject ) => {
            const scriptElement = document.createElement( 'script' );
            scriptElement.setAttribute( 'src', src );
            scriptElement.setAttribute( 'async', "" );
            scriptElement.addEventListener( 'load', resolve );
            scriptElement.addEventListener( 'error', reject );
            document.body.appendChild( scriptElement );
        } );
    }
    try {
        addScript( `https://www.googletagmanager.com/gtag/js?id=${tag}` ).then( ( data ) => {} ).catch( ( e ) => {
            console.log( e );
        } );    window.dataLayer = window.dataLayer || [];
        
        function gtag() {
            dataLayer.push( arguments );
        }
        gtag( 'js', new Date() );
        gtag( 'config', tag );
    } catch ( e ) {
        console.log( e );
    }
  4. Go to '[my/ca/au/eu].oneplan.ai/config/js'. Paste the code into the Custom JavaScript form.

  5. Replace YOUR_GOOGLE_TAG_ID_HERE with your Google Tag ID that you got from the previous section.

  6. Click Save.