Title: Datalayer
Last modified: May 24, 2023

---

# Datalayer

 *  Resolved [pauline684](https://wordpress.org/support/users/pauline684/)
 * (@pauline684)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/)
 * Hello,
 * I need to implement a datalayer on the order confirmation page of my e-commerce
   website (like this example [https://youtu.be/fDuwmudV-oU?t=244](https://youtu.be/fDuwmudV-oU?t=244)).
 * I used an installation guide from Google : [https://developers.google.com/tag-platform/tag-manager/web/datalayer?hl=fr](https://developers.google.com/tag-platform/tag-manager/web/datalayer?hl=fr).
 * However, how can I install the code before the google tag manager code knowing
   that I’m using Google site kit please ?
 * Here is the code :
 *     ```wp-block-code
       <script>
       window.dataLayer = window.dataLayer || [];
       </script>
       ```
   
 * from
 *     ```wp-block-code
       <script>
       window.dataLayer = window.dataLayer || [];
       </script>
       <!-- Google Tag Manager -->
       <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
       new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
       j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
       'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
       })(window,document,'script','dataLayer','GTM-XXXXXX');</script>
       <!-- End Google Tag Manager -->
       ```
   
 * There may be better solutions to install a datalayer, I am open to all proposals.
   😊
 * Thank you for your answer !
 * Good day

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16767424)
 * Thanks for reaching out [@pauline684](https://wordpress.org/support/users/pauline684/).
   There is a data layer object added to users sites via Site Kit if you have Analytics
   inserted via the plugin. You’ll see this below:
 * ![](https://i0.wp.com/i.imgur.com/mLMbX5x.png?ssl=1)
 * You can add elements to this snippet via a `googlesitekit_gtag_opt` filter. I’m
   happy to provide you with information on how to do so if you wish.
 * If you’re looking to add data layer information for Tag Manager specifically,
   you can reach out to the product experts at the [Tag Manager Help Center](https://support.google.com/tagmanager/?hl=en#topic=3441530).
   Site Kit doesn’t provide any features for editing the Tag Manager snippet placed
   via the plugin. You can place your own Tag Manager snippet if you wish, independent
   of Site Kit.
 * Let me know if you have any questions with the above.
 *  Thread Starter [pauline684](https://wordpress.org/support/users/pauline684/)
 * (@pauline684)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16767574)
 * Hello [@jamesosborne](https://wordpress.org/support/users/jamesosborne/)
 * Thank you for your answer. 😊
 * How can I access the datalayer on the order validation page please (I inserted
   Analytics via Google Site kit) ?
 * What is the utility to add elements to the Analytics snippet via a googlesitekit_gtag_opt
   filter ? Will this allow me to have something similar to the datalayer on the
   YouTube video (from 4:04) ?
 * Thanks
 * Good day
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16767645)
 * > How can I access the datalayer on the order validation page please (I inserted
   > Analytics via Google Site kit) ?
 * Unfortunately this isn’t something we can assist with here in the Site Kit plugin
   forums. For event tracking or data layer configurations you can reach out in 
   the Tag Manager Help Center, where the product experts can assist further. You
   can apply these configurations at Tag Manager level, ensuring events fire on 
   certain conditions or pages.
 * You’ll see an example of how to add options to the Analytics snippet below:
 *     ```wp-block-code
       add_filter('googlesitekit_gtag_opt',function( $opt ) {
        $opt['optimize_id'] = 'OPT-WDTK3DZ';
        return $opt;
       });
       ```
   
 * The above adds an Optimize container ID to a users site. You could add other 
   configurations by replacing the _optimize\_id_ setting and the associated value(
   OPT-WDTK3**).
 *  Thread Starter [pauline684](https://wordpress.org/support/users/pauline684/)
 * (@pauline684)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16768276)
 * Okay, so I need to ask the Tage manager service to help me install the Analytics
   snippet, right ? 😊
 *     ```wp-block-code
       add_filter('googlesitekit_gtag_opt',function( $opt ) {
        $opt['optimize_id'] = 'OPT-WDTK3DZ';
        return $opt;
       });
       ```
   
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16768406)
 * Hi [@pauline684](https://wordpress.org/support/users/pauline684/). For the snippet
   provided above, this is for an Analytics snippet modification only, if you’re
   using Site Kit to place your Analytics snippet. You can add various customizations
   in here.
 * To setup event tracking or data layers, this must be done at Tag Manager level.
   You can reach out in the [Tag Manager Help Center](https://support.google.com/tagmanager/?hl=en#topic=3441530)
   for assistance with this. You’ll also find details on this [here](https://sitekit.withgoogle.com/documentation/using-site-kit/event-tracking/).
 *  Thread Starter [pauline684](https://wordpress.org/support/users/pauline684/)
 * (@pauline684)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16768824)
 * Noted, thank you for your help 😊
 * Good day
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16768844)
 * No problem, thanks for reaching out. Get in touch if you have any further Site
   Kit queries.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Datalayer’ is closed to new replies.

 * ![](https://ps.w.org/google-site-kit/assets/icon-256x256.png?rev=3141863)
 * [Site Kit by Google - Analytics, Search Console, AdSense, Speed](https://wordpress.org/plugins/google-site-kit/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-site-kit/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-site-kit/)
 * [Active Topics](https://wordpress.org/support/plugin/google-site-kit/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-site-kit/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-site-kit/reviews/)

## Tags

 * [datalayer](https://wordpress.org/support/topic-tag/datalayer/)

 * 7 replies
 * 2 participants
 * Last reply from: [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/datalayer/#post-16768844)
 * Status: resolved