# Google Analytics Code erweitern

**URL:** <https://forum.shopware.com/t/google-analytics-code-erweitern/37770>\
**Category:** Allgemein\
**Created:** [28. Juni 2016 um 16:06 UTC](https://forum.shopware.com/t/google-analytics-code-erweitern/37770 "2016-06-28T16:06:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_tian](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@Chris\_tian](https://forum.shopware.com/u/Chris_tian)\
**Post date:** [28. Juni 2016 um 16:06 UTC](https://forum.shopware.com/t/google-analytics-code-erweitern/37770/1 "2016-06-28T16:06:21Z")

</div>

Hallo zusammen,

ich muss einen Javascript-Code vor dem Analytics Code im Quelltext einbinden, um ein Cookie Opt-Out zu ermöglichen. Kann mir jemand sagen, wie ich das einbinden muss?

```
// Set to the same value as the web property used on the site
var gaProperty = 'UA-XXXXXX-Y';
var disableStr = 'ga-disable-' + gaProperty;
 
// Disable tracking if the opt-out cookie exists.
if (document.cookie.indexOf(disableStr + '=true') > -1) {
  window[disableStr] = true;
}
 
// Opt-out function
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
}

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![ffinkelm](https://avatars.discourse-cdn.com/v4/letter/f/fbc32d/32.png) [@ffinkelm](https://forum.shopware.com/u/ffinkelm)\
**Post date:** [8. Dezember 2016 um 18:45 UTC](https://forum.shopware.com/t/google-analytics-code-erweitern/37770/2 "2016-12-08T18:45:27Z")

</div>

Habe ich auch Interesse dran, wird wieder zur Abmahnfalle.

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [8. Dezember 2016 um 21:59 UTC](https://forum.shopware.com/t/google-analytics-code-erweitern/37770/3 "2016-12-08T21:59:00Z")

</div>

Nutzt ihr das Analytics Plugin von Shopware ?&nbsp;Dann in den&nbsp;Plugin-Einstellungen einfach „IP anonymisieren“ anklicken.

---

<div class="post-metadata">

**Author:** ![Chris\_tian](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@Chris\_tian](https://forum.shopware.com/u/Chris_tian)\
**Post date:** [9. Dezember 2016 um 09:14 UTC](https://forum.shopware.com/t/google-analytics-code-erweitern/37770/4 "2016-12-09T09:14:50Z")

</div>

Das ist doch etwas anderes oder? Durch den&nbsp;Cookie Opt-Out, wird auch das Remarketing-Tracking verhindert.

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [9. Dezember 2016 um 09:39 UTC](https://forum.shopware.com/t/google-analytics-code-erweitern/37770/5 "2016-12-09T09:39:55Z")

</div>

sorry, stimmt, habe mich vertan. Man muss ja 2 JavaScripte einfügen.

Also ich habe den JS-Code in eine neue Datei namens &nbsp;\_public/src/js/gaoptout.js&nbsp;ausgelagert

und dann in&nbsp; frontend/index/index.tpl eingebunden:

&nbsp;

```
{block name="frontend_index_header_javascript_jquery_lib" append}
     
{/block}

```

also bei mir werden hier die \< und \> Zeichen immer in html-Entities umgewandelt… also \< entspricht \< und \> \>
