Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Google Adwords Conversion (neue Adwords Oberfläche)

    lotus-eater

    • Neu im Forum
    • Beiträge: 7
    Hi,

    ich hab unter admin/Erw.Konfiguration/Partner die Conversion ID und das Google Conversion Label eingetragen, allerdings die Parameter für den Google Tag Manager.

    Anscheinend gibt es zwei Oberflächen. Schaut man in der Hilfe nach, ähnelt das Snippet für die alte Oberfläsche eher dem Code im Shop.
    https://support.google.com/adwords/answer/6095821

    Ist die neue Adwords Oberfläsche kompatible mit der Shop-Software?

    Meine Shop Version: modified eCommerce Shopssoftware v2.0.3.0 rev 10907

    Linkback: https://www.modified-shop.org/forum/index.php?topic=39207.0

    lotus-eater

    • Neu im Forum
    • Beiträge: 7
    Re: Google Adwords Conversion (neue Adwords Oberfläche)
    Antwort #1 am: 14. Juni 2018, 16:47:50
    So,
    ich versuche mal den Code auf gtag umzubauen. Es soll alles in das head-Element rein, deswegen setzte ich bei includes/extra/header/header_head/gtag.js.php an.
    includes/extra/header/header_body/google_conversiontracking.js.php braucht man dann nicht mehr und in den template muss in der index.html der Code
    Code: Javascript  [Auswählen]
      {if $smarty.const.TRACKING_GOOGLEANALYTICS_ACTIVE == 'true'}
        {googleanalytics account=$smarty.const.TRACKING_GOOGLEANALYTICS_ID}
      {/if}
     
    entfernt werden.

    Code: PHP  [Auswählen]
    <?php
    // GOOGLE CONV. TRACKING
    $show_google_conversion_event = (basename($PHP_SELF) == FILENAME_CHECKOUT_SUCCESS && GOOGLE_CONVERSION == 'true');
    if ($show_google_conversion_event) {
      require_once (DIR_FS_INC.'get_order_total.inc.php');
      $total = get_order_total($last_order);
    }
    ?>

    <?php if (TRACKING_GOOGLEANALYTICS_ACTIVE == 'true'): ?>

    <script type="text/javascript">
      // Set to the same value as the web property used on the site
      var gaProperty = '<?= GOOGLE_GOOGLEANALYTICS_ID ?>'\';

      // Disable tracking if the opt-out cookie exists.
      var disableStr = 'ga-disable-' + gaProperty;
      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;
      }
    </script>

    <?php
        // cache analytics.js
        $cache_gs = DIR_FS_CATALOG.'cache/gtag.js';
        if (!is_file($cache_gs) || (time() - filemtime($cache_gs) > 3600)) {
          require_once(DIR_FS_INC.'get_external_content.inc.php');
          $source_gs = get_external_content('https://www.googletagmanager.com/gtag/js', 2, false);
          if (file_put_contents($cache_gs, $source_gs, LOCK_EX) !== false) {
            $gs = xtc_href_link('cache/gtag.js', '', $request_type, false);
          }
        } elseif (is_file($cache_gs)) {
          $gs = xtc_href_link('cache/gtag.js', '', $request_type, false);
        }

        $config_prop = ['anonymize_ip' => true];
        if (TRACKING_GOOGLE_LINKID == 'true'){
          $config_prop['link_attribution'] = true;
        }

        if (TRACKING_GOOGLE_DISPLAY == 'true'){
          $config_prop['allow_display_features'] = true;
        }

        $config_prop_txt = json_encode($config_prop);
    ?>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="<?= isset($gs)?$gs:'https://www.googletagmanager.com/gtag/js'?>"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', '<?= TRACKING_GOOGLEANALYTICS_ID ?>', <?= $config_prop_txt ?>);
      <?php if (GOOGLE_CONVERSION): ?>
      gtag('config', '<?= GOOGLE_CONVERSION_ID ?>', <?= $config_prop_txt ?>);
      <?php endif; ?>
    </script>

    <?php endif; ?>

    <?php if ($show_google_conversion_event): ?>
    <!-- Event snippet for Verkauf conversion page -->
    <script>
      gtag('event', 'conversion', {
          'send_to': '<?= GOOGLE_CONVERSION_ID ?>/<?= GOOGLE_CONVERSION_LABEL ?>',
          'value': <?= $total ?>,
          'currency': 'EUR',
          'transaction_id': ''
      });
    </script>
    <?php endif; ?>

     

    Es bleiben noch ein paar Punkte offen:

    Was haltet ihr davon? Kann man das so nutzen?

    lotus-eater

    • Neu im Forum
    • Beiträge: 7
    Re: Google Adwords Conversion (neue Adwords Oberfläche)
    Antwort #2 am: 14. Juni 2018, 19:41:25
    Noch mit eingearbeitet, dass Aufrufe durch die Admins nicht gezählt werden, wenn es so im Adminbereich eingstellt ist. Außerdem noch einen kleinen Fehler im disableStr verbessert.

    includes/extra/header/header_head/gtag.js.php:
    Code: PHP  [Auswählen]
    <?php
    if (TRACKING_GOOGLEANALYTICS_ACTIVE == 'true'): ?>
    <script type="text/javascript">
      // Disable tracking if the opt-out cookie exists.
      var disableStr = 'ga-disable-<?= TRACKING_GOOGLEANALYTICS_ID ?>';
      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;
      }
    </script>
    <?php endif;

    if ($_SESSION["customers_status"]["customers_status_id"] == '0' && TRACKING_COUNT_ADMIN_ACTIVE != 'true') return;

    // GOOGLE CONV. TRACKING
    $show_google_conversion_event = (basename($PHP_SELF) == FILENAME_CHECKOUT_SUCCESS && GOOGLE_CONVERSION == 'true');
    if ($show_google_conversion_event) {
      require_once (DIR_FS_INC.'get_order_total.inc.php');
      $total = get_order_total($last_order);
    }
    ?>

    <?php if (TRACKING_GOOGLEANALYTICS_ACTIVE == 'true'): ?>

    <?php
        // cache gtag.js
        $cache_gs = DIR_FS_CATALOG.'cache/gtag.js';
        if (!is_file($cache_gs) || (time() - filemtime($cache_gs) > 3600)) {
          require_once(DIR_FS_INC.'get_external_content.inc.php');
          $source_gs = get_external_content('https://www.googletagmanager.com/gtag/js', 2, false);
          if (file_put_contents($cache_gs, $source_gs, LOCK_EX) !== false) {
            $gs = xtc_href_link('cache/gtag.js', '', $request_type, false);
          }
        } elseif (is_file($cache_gs)) {
          $gs = xtc_href_link('cache/gtag.js', '', $request_type, false);
        }

        $config_prop = ['anonymize_ip' => true];
        if (TRACKING_GOOGLE_LINKID == 'true'){
          $config_prop['link_attribution'] = true;
        }

        if (TRACKING_GOOGLE_DISPLAY == 'true'){
          $config_prop['allow_display_features'] = true;
        }

        $config_prop_txt = json_encode($config_prop);
    ?>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="<?= isset($gs)?$gs:'https://www.googletagmanager.com/gtag/js'?>"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', '<?= TRACKING_GOOGLEANALYTICS_ID ?>', <?= $config_prop_txt ?>);
      <?php if (GOOGLE_CONVERSION): ?>
      gtag('config', '<?= GOOGLE_CONVERSION_ID ?>', <?= $config_prop_txt ?>);
      <?php endif; ?>
    </script>

    <?php endif; ?>

    <?php if ($show_google_conversion_event): ?>
    <!-- Event snippet for Verkauf conversion page -->
    <script>
      gtag('event', 'conversion', {
          'send_to': '<?= GOOGLE_CONVERSION_ID ?>/<?= GOOGLE_CONVERSION_LABEL ?>',
          'value': <?= $total ?>,
          'currency': 'EUR',
          'transaction_id': ''
      });
    </script>
    <?php endif; ?>
     
    26 Antworten
    24034 Aufrufe
    12. September 2013, 20:43:34 von billybob
    9 Antworten
    9998 Aufrufe
    22. September 2016, 15:05:22 von rosslara
    1 Antworten
    1818 Aufrufe
    27. September 2017, 13:21:39 von lukass
    1 Antworten
    3025 Aufrufe
    17. Mai 2018, 22:46:29 von HaldOn