E-Commerce Marketing, Marketing Digitale

Gestione Consenso

E-Commerce Marketing, Marketing Digitale

Gestione Consenso

<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”cookie2.aspx.vb” Inherits=”cookie2″ %>

 

<!DOCTYPE html>

 

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

    <title>ASP.NET Page with Bootstrap Modal</title>

    <!– Includi il foglio di stile Bootstrap CSS –>

    <link rel=”stylesheet” href=”https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css” />

</head>

<body>

 

 

 

 

    <script>

        window.dataLayer = window.dataLayer || [];

        function gtag() { dataLayer.push(arguments); }

        gtag(‘consent’, ‘default’, {

            ‘ad_user_data’: ‘denied’,

            ‘ad_personalization’: ‘denied’,

            ‘ad_storage’: ‘denied’,

            ‘analytics_storage’: ‘denied’,

            ‘wait_for_update’: 500,

        });

        gtag(‘js’, new Date());

        gtag(‘config’, ‘G-2LMLDKP7RR’);

    </script>

 

 

 

    <form id=”form1″ runat=”server”>

    <!– Modal –>

    <div class=”modal fade” id=”modal-3″ tabindex=”-1″ role=”dialog” aria-labelledby=”modal-label-3″ aria-hidden=”true”>

        <div class=”modal-dialog modal-lg”>

            <div class=”modal-content”>

                <div class=”modal-header”>

                    <h4 id=”modal-label-3″ class=”modal-title”>Large Modal</h4>

                    <button aria-hidden=”true” data-dismiss=”modal” class=”close” type=”button”>×</button>

                </div>

                <div class=”modal-body”>

                    <div class=”row mb20″>

                        <div class=”col-md-12″>

                            <p>

                                I cookie sono piccoli file di testo che possono essere utilizzati dai siti web per rendere più efficiente l’esperienza per l’utente.

 

La legge afferma che possiamo memorizzare i cookie sul tuo dispositivo se sono strettamente necessari per il funzionamento di questo sito. Per tutti gli altri tipi di cookie ci serve il tuo permesso.

 

Questo sito utilizza diversi tipi di cookie. Alcuni cookie sono posti da servizi di terzi che compaiono sulle nostre pagine. 

                            </p>

                        </div>

                    </div>

                    <div class=”row”>

                        <div class=”col-md-6 xs-box”>

                            <div class=”box-services-a”>

                                <h3>Statistics</h3>

                                <asp:CheckBox ID=”CheckBox1″ runat=”server” Text=”Consent to Statistics” />

                            </div>

                        </div>

                        <div class=”col-md-6″>

                            <div class=”box-services-a”>

                                <h3>Marketing</h3>

                                <asp:CheckBox ID=”CheckBox2″ runat=”server” Text=”Consent to Marketing” />

                            </div>

                        </div>

                    </div>

                </div>

                <div class=”modal-footer”>

                    <!– Button to close the modal –>

                    <asp:Button ID=”Button1″ runat=”server” Text=”Close” CssClass=”btn btn-secondary” />

                    <!– Button to grant consent –>

                    <asp:Button ID=”GrantConsentButton” runat=”server” Text=”Accetto i Cookie” CssClass=”btn btn-primary” />

                </div>

            </div>

        </div>

    </div>

 

    <!– Label to display the status of consent –>

    <asp:Label ID=”LabelService1″ runat=”server” Text=””></asp:Label>

    <asp:Label ID=”LabelService2″ runat=”server” Text=””></asp:Label>

</form>

 

<!– Include jQuery and Bootstrap JavaScript –>

<script src=”https://code.jquery.com/jquery-3.6.0.min.js”></script>

<script src=”https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js”></script>

 

<script>

    $(document).ready(function () {

       

        var statisticsConsent = localStorage.getItem(“statisticsConsent”);

        var marketingConsent = localStorage.getItem(“marketingConsent”);

 

        if (statisticsConsent === null || marketingConsent === null) {

            setTimeout(function () {

                $(‘#modal-3’).modal(‘show’);

            }, 3000);

        }

    });

 

    $(‘#GrantConsentButton’).click(function () {

       

        var statisticsConsent = $(‘#<%= CheckBox1.ClientID %>’).prop(‘checked’);

        var marketingConsent = $(‘#<%= CheckBox2.ClientID %>’).prop(‘checked’);

 

       

        $(‘#<%= LabelService1.ClientID %>’).text(‘Statistics consent: ‘ + statisticsConsent);

        $(‘#<%= LabelService2.ClientID %>’).text(‘Marketing consent: ‘ + marketingConsent);

 

       

        gtag(‘consent’, ‘update’, {

            ad_user_data: statisticsConsent ? ‘granted’ : ‘denied’,

            ad_personalization: statisticsConsent ? ‘granted’ : ‘denied’,

            ad_storage: marketingConsent ? ‘granted’ : ‘denied’,

            analytics_storage: marketingConsent ? ‘granted’ : ‘denied’

        });

 

       

        localStorage.setItem(“statisticsConsent”, statisticsConsent);

        localStorage.setItem(“marketingConsent”, marketingConsent);

 

       

        if (statisticsConsent || marketingConsent) {

            var gtagScript = document.createElement(‘script’);

            gtagScript.async = true;

            gtagScript.src = ‘https://www.googletagmanager.com/gtag/js?id=G-2LMLDKP7RR’;

            var firstScript = document.getElementsByTagName(‘script’)[0];

            firstScript.parentNode.insertBefore(gtagScript, firstScript);

        }

 

       

        $(‘#modal-3’).modal(‘hide’);

    });

</script>

</body>

</html>

Articoli collegati