# Modules

## Tawkto

<!-- panels:start -->
<!-- div:title-panel -->

### Integration

<!-- div:left-panel -->

Tawkto integration code.<br>
Paste the code  into the `<head>` tag of your website.

?> **Response Type:** Illuminate\Support\Array<br>
**Response Content:** [0 => tawkto_asset_identity, 1 => tawkto_widget_id]

<!-- div:right-panel -->

<!-- tabs:start -->

#### **Code**

```php
get_tawkto_code();
```

#### **Example**

```php
@php
    $tawkto = get_tawkto_code();
@endphp
@if ($tawkto)
    <!--Start of Tawk.to Script-->
    <script type="text/javascript">
        var Tawk_API = Tawk_API || {},
            Tawk_LoadStart = new Date();
        (function() {
            var s1 = document.createElement("script"),
                s0 = document.getElementsByTagName("script")[0];
            s1.async = true;
            s1.src = 'https://embed.tawk.to/{{ $tawkto[0] }}/{{ $tawkto[1] }}';
            s1.charset = 'UTF-8';
            s1.setAttribute('crossorigin', '*');
            s0.parentNode.insertBefore(s1, s0);
        })();
    </script>
    <!--End of Tawk.to Script-->
@endif
```

#### **Inspect**

```php
function get_tawkto_code()
{
    $tawkto_asset_identity = SiteSetting::where('key', 'tawkto_asset_identity')->first()->value ?? '';
    $tawkto_widget_id = SiteSetting::where('key', 'tawkto_widget_id')->first()->value ?? '';

    if ($tawkto_asset_identity && $tawkto_widget_id) {
        return [
            $tawkto_asset_identity,
            $tawkto_widget_id
        ];
    }
    return false;
}
```

<!-- tabs:end -->

<!-- panels:end -->

## Google Analytics

<!-- panels:start -->
<!-- div:title-panel -->

### Integration

<!-- div:left-panel -->

Google analytics integration code.<br>
Paste the code  into the `<head>` tag of your website.

<!-- div:right-panel -->

<!-- tabs:start -->

#### **Code**

```php
@php
    $google_analytics_code = get_site_setting('google_analytics_code');
@endphp
@if ($google_analytics_code)
    <!-- Google tag (gtag.js) -->
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ $google_analytics_code }}"></script>
    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }
        gtag('js', new Date());

        gtag('config', '{{ $google_analytics_code }}');
    </script>
@endif
```

<!-- tabs:end -->

<!-- panels:end -->

## Yandex Metrica

<!-- panels:start -->
<!-- div:title-panel -->

### Integration

<!-- div:left-panel -->

Yandex Metrica integration code.<br>
Paste the code  into the `<head>` tag of your website.

<!-- div:right-panel -->

<!-- tabs:start -->

#### **Code**

```php
@php
    $yandex_metrica_code = get_site_setting('yandex_metrica_code');
@endphp
@if ($yandex_metrica_code)
    <!-- Yandex.Metrica counter -->
    <script type="text/javascript">
        (function(m, e, t, r, i, k, a) {
            m[i] = m[i] || function() {
                (m[i].a = m[i].a || []).push(arguments)
            };
            m[i].l = 1 * new Date();
            for (var j = 0; j < document.scripts.length; j++) {
                if (document.scripts[j].src === r) {
                    return;
                }
            }
            k = e.createElement(t), a = e.getElementsByTagName(t)[0], k.async = 1, k.src = r, a.parentNode.insertBefore(
                k, a)
        })
        (window, document, "script", "https://mc.yandex.ru/Metrica/tag.js", "ym");

        ym({{ $yandex_metrica_code }}, "init", {
            clickmap: true,
            trackLinks: true,
            accurateTrackBounce: true,
            webvisor: true,
            ecommerce: "dataLayer"
        });
    </script>
    <noscript>
        <div><img src="https://mc.yandex.ru/watch/{{ $yandex_metrica_code }}"
                style="position:absolute; left:-9999px;" alt="" /></div>
    </noscript>
    <!-- /Yandex.Metrica counter -->
@endif
```

<!-- tabs:end -->

<!-- panels:end -->
