Google Tag Manager

Initialize the LogRocket JavaScript SDK with Google Tag Manager

If you use Google Tag Manager to manage third party scripts, you can use it to initialize LogRocket on your application. You will need to create a tag for the LogRocket script, and select a trigger for it. We recommend using the Window Loaded trigger.

If you do not already have an app ID, visit to get one. Once you have an app ID, insert it into the script tag as shown below.

Add to your HTML:

<script src=""></script>
<script>window.LogRocket && window.LogRocket.init('YOUR_ORG_ID/YOUR_APP_ID');</script>

Create a new Custom HTML tag in your Google Tag Manager instance and add both lines of the LogRocket script tag.


Select a trigger for the tag. We recommend Window Loaded. You can also use Page View.



Gathering more data with LogRocket in GTM

All methods available with the LogRocket JavaScript SDK are available when initializing via Google Tag Manager. These include user identification, DOM sanitization and network sanitization, along with custom events.