• Resolved pauline684

    (@pauline684)


    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).

    I used an installation guide from Google : 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 :

    <script>
    window.dataLayer = window.dataLayer || [];
    </script>

    from

    <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

    (@jamesosborne)

    Thanks for reaching out @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:

    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. 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

    (@pauline684)

    Hello @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

    (@jamesosborne)

    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:

    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

    (@pauline684)

    Okay, so I need to ask the Tage manager service to help me install the Analytics snippet, right ? ??

    add_filter('googlesitekit_gtag_opt',function( $opt ) {
     $opt['optimize_id'] = 'OPT-WDTK3DZ';
     return $opt;
    });
    Plugin Support James Osborne

    (@jamesosborne)

    Hi @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 for assistance with this. You’ll also find details on this here.

    Thread Starter pauline684

    (@pauline684)

    Noted, thank you for your help ??

    Good day

    Plugin Support James Osborne

    (@jamesosborne)

    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.