Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I test Google Tag manager locally

Tags:

I have created a GTM container, added tags under it and published.

its in debug mod and I can see datalayer

but for tags, says there are not tags in container

even though tags are there in container rules and tags

so question is, can I test gtm account on local machine even domain url of gtm is live.

if yes then why tags are not showing? does Google take time in publishing tags?

I tried google chrome plugin but it only shows basic info,

I want to work it like if I click on a product or do a purchase locally, it should update data for account remotely, is it possible?

like image 670
murtza gondal Avatar asked Nov 06 '14 08:11

murtza gondal


People also ask

Can I test Google Analytics on localhost?

Both Global Site Tag - gtag. js and Universal Analytics - analytics. js will detect localhost automatically. You do not need to make any change to the configuration.

How do I test a GTM dataLayer?

A third way to find your data layer information is using the console tab in developer tools. Simply type “dataLayer” into the console, and voila, there's your data layer. Click the down arrow next to the data layer array, and you can see the different objects inside.


1 Answers

Google Tag Manager can be easily tested on your local machine (no need for a Chrome extension), similar to how you would Preview your changes on a public website/app:

  1. Setup your Google Tag Manager account.
  2. Add the <!-- Google Tag Manager --> script to the <head> of your webpage(s).
  3. Add the <!-- Google Tag Manager (noscript) --> to the <body> of your webpage(s) (optional).
  4. Make the required updates in Google Tag Manager - e.g. add a new tag, etc.
  5. Click Preview in Google Tag Manager.
  6. Wait for the 'Now Previewing Workspace' banner to show in Google Tag Manager.
  7. Start a local web server to run your app - this method will vary depending on your local setup but you should be able to access your app using a local URL like localhost:8088/.

    NOTE: Opening a file path (e.g. file:///Users/your-name/Documents/) in your browser WILL NOT work.

  8. In the same browser as Google Tag Manager is open, open a new tab and go to your local web server URL - e.g localhost:8088.
  9. The Google Tag Manager debug pane should be visible at the bottom of the browser window.
like image 94
Brett DeWoody Avatar answered Sep 24 '22 00:09

Brett DeWoody