VERSICH

Setting Up Google Tag Manager with NetSuite SuiteCommerce

setting up google tag manager with netsuite suitecommerce

Google Tag Manager works seamlessly with NetSuite. This free tool allows businesses to enhance their data gathering and performance tracking effectively.

If you're looking to boost your Search Engine Optimization (SEO) and attract more visitors to your site for increased revenue, Google Tag Manager integrates directly with NetSuite. It's one of the many free tools businesses like yours can employ to optimize data collection and analyze performance.

Google Tag Manager vs. Google Analytics 4 (GA4)

Google Tag Manager is one of the essential free tools available to companies, alongside Google Analytics (GA4), which integrates effortlessly as well. As you consider which tool to use, it's crucial to recognize that these platforms serve different purposes.

Google Tag Manager

  • Handles tags or scripts without altering the source code.

  • Lacks reporting features but simplifies data collection and provides insights into your company’s performance.

Google Analytics (GA4)

  • Gathers and analyzes user data based on their interactions with your application or site.

  • Delivers reports on user behavior and engagement metrics.

The rest of this guide will focus solely on Google Tag Manager.

To set up Google Tag Manager, you will require access to both your NetSuite account as an Admin and your Google business account.

Step 1: Install the SC Google Tag Manager Editor

To install and activate the “SC Google Tag Manager Editor” bundle in your NetSuite environment, follow these steps:

Install SuiteCommerce Applications

  • Navigate to Customization > SuiteBundler > Search & Install Bundles.

  • Install all necessary SuiteApps (bundles) for your implementation. In the Keywords field, type “SC Google Tag Manager Editor” and click Search.

Step 2: Sign Up for Google Tag Manager

Register for Google Tag Manager (GTM)

  • Visit Website Tag Management Tools & Solutions - Google Tag Manager.

  • Log in to GTM using your Google ID.

  • Click Create Account and provide a name for your account.

  • Choose your country from the Country dropdown and click Continue.

  • Enter your site's name in the Container Name field.

  • Select Web from the Where to Use Container dropdown.

  • Click Create.

  • Close the Install Google Tag Manager window.

  • Access the GTM Workspace tab and note the GTM ID found in the submenu header area at the upper right of the page.

Google Tag Manager ID is displayed here.

Step 3: Authenticate your NetSuite Account with the Google API

Google necessitates that you authenticate your NetSuite account with the Google API using a Google OAuth Client ID. Follow these steps to create a free Google OAuth Client ID and link it to your NetSuite account:

1. Create your Google API OAuth Client ID credentials.

  • Sign in to the Google API Credentials Console using your Google account information.

  • Click Create credentials > OAuth client ID.

  • On the credentials form, select Web application as your application type.

  • Input NetSuite in the Name field.

  • Populate your Authorized JavaScript origins and Authorized redirect URIs (Uniform Resource Identifiers).

  • Click Create. A message will display your OAuth client ID and client secret.

  • Note your OAuth client ID and click OK.

2. Fill out your Google API OAuth consent screen values.

  • Again, log in to the Google API Credentials Console using your Google account credentials.

  • Click Credentials in the left navigation menu.

  • Select the OAuth consent screen tab.

  • Enter the information indicated in the following table.

  • Click Save.

3. Connect your Google API OAuth client ID to your NetSuite account.

  • In NetSuite, navigate to Setup > Company > General Preferences.

  • Access the Custom Preferences tab.

  • Input or paste your OAuth Client ID in the Google OAuth Client ID field.

  • Click Save.

Setup > Company > General Preferences

Insert your Google OAUTH Client ID here.

Step 4: Connect your Google Tag Manager Account to a Domain

To associate your Google Tag Manager account with your domain:

  • Go to Commerce > Web Sites > Configuration. Select your website and domain, then click Configure.

  • In the configuration record, open the Integrations tab and the Google Tag Manager subtab.

  • Enter your GTM ID in the Google Tag Manager ID field. Keep the Google Tag Manager Data Name field at its default value of dataLayer.

  • If you utilize separate domains for shopping and checkout, tick the Is A Multi-Domain Site box.

  • Click Save.

Commerce > Websites > Configuration - Integrations Tab and Google Tag Manager Sub Tab

Step 5: Add Services to Your Google Tag Manager Container

  • In NetSuite, go to Setup > SuiteCommerce Advanced > Google Tag Manager Editor.

  • Click Sign In With Google and select your account.

  • Authorize NetSuite to access your Google account by clicking Allow for each requested permission.

  • On the Accounts & Containers - Google Tag Manager Editor page, select your container name.

  • Click Add Service.

  • Choose the service you want to add from the Service dropdown.

  • Complete the fields associated with the service you are adding. Each service will require different information. For example, if adding the Google Analytics service, you must enter a unique name, your Google Analytics tracking ID, and the domains you want to associate with this service. Click the question mark icon for more details on retrieving these values.

  • Click Add. If an instance of the service already exists, a warning will appear with a link to modify the current service. If there are multiple instances, a warning will display with a link to the list of available container services.

In NetSuite, Set Up > SuiteCommerce Advanced > Google Tag Manager Editor

Step 6: Review and Publish Changes in your Google Console

To review and publish your updates:

  • From the Container Services page in the GTM, click Review and Publish Changes. This will redirect you to your workspace and container in GTM.

  • On the GTM Workspace page, click Submit.

  • On the Submit Changes page, you can add a version name and description. While these fields are optional, they help identify the updates made to your container.

  • Click Publish.

Step 7: Retain Google Tag Manager Session Data

You've put in the effort to gather valuable data, now it's vital to maintain it. You have four options for storing this data.

1. Enable SuiteScript and Custom Records

This step outlines how to enable SuiteScript and custom records within NetSuite.

To activate SuiteScript and Custom Records:

  • In NetSuite, go to Setup > Company > Enable Features.

  • Switch to the SuiteCloud tab. In the SuiteBuilder section, check the Custom Records box.

  • In the SuiteScript section, select the following options: Client SuiteScript, Server SuiteScript, SuiteScript Server Pages.

  • Click Save.

2. Create a Custom Record

This step explains how to set up custom records that will store data across sessions.

To establish a custom record:

  • In NetSuite, navigate to Customization > Lists, Records & Fields > Record Types > New.

  • In the Name field, input a name for your custom record.

  • Example: SC GTM DataLayer

  • In the ID field, type: _ns_gtm_datalayer.

  • Ensure that this value is exact (including the leading underscore character).

  • From the Access Type dropdown, select No Permission Required.

  • Uncheck the Include Name Field box.

  • Click Save.

  • The new Custom Record Type page appears. The title of your new record type will show in the Name field.

  • Access the Fields tab and add two fields: gtm_id and gtm_events. Utilize the settings and values outlined in the following table.

3. Create Scheduler File

This step describes how to set up a scheduler file that will delete unnecessary session data records every hour.

Using a text editor, create a JavaScript file named gtmScheduler.js. Input the following code:

```javascript function gtmScheduleController() { var gtm_record = 'customrecord_ns_gtm_datalayer' , gtm_record_column = new nlobjSearchColumn('lastmodified') , gtm_record_list = nlapiSearchRecord(gtm_record, null, null, gtm_record_column) || []; gtm_record_list.forEach(function(record) { var record_saved_date = nlapiStringToDate ( record.getValue('lastmodified'), 'datetime').getTime() , current_date = new Date().getTime(); if(current_date - record_saved_date <= 3600) { nlapiDeleteRecord(gtm_record, record.id); } }); } ```

4. Create Scheduler Script

This step guides you on how to create the scheduler script that operates every 60 minutes.

In NetSuite, upload your script file:

  • Go to Customization > Scripting > Scripts > New.

  • In the Scripts File field, click the Plus icon (+).

  • Click Choose File.

  • Locate your local files to select the gtmScheduler.js file.

  • Click Open.

  • Click Save.

Next, establish the script record:

  • Click Create Script Record.

  • Choose Scheduled.

  • In the Name field, enter: SC GTM Scheduler.

  • In the ID field, enter: _ns_gtm_scheduler_script.

  • On the Scripts tab, in the Function field, enter: gtmScheduleController.

  • On the Deployments tab, click Add and set the desired values.

  • Click Deploy Script.

Oracle NetSuite Alliance Partner & Commerce Partner

If you have inquiries about how our services can assist your business in implementing NetSuite or SuiteCommerce, don’t hesitate to ask. Versich is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to tackle various NetSuite and SuiteCommerce projects, regardless of size.

Looking for SuiteCommerce Solutions?

Explore our expert SuiteCommerce services and get started today.

Get Started
CTA Illustration