Is google_analytics_counter component valid?

Created on 20 May 2025, about 1 month ago

Problem/Motivation

In \Drupal\google_analytics_counter\GoogleAnalyticsCounterCustomFieldGenerator::gacAddField, the GAC field is being added to the default and teaser view modes:

// Assign display settings for the 'default' and 'teaser' view modes.
      $this->entityDisplayRepository
        ->getViewDisplay('node', $type->id(), 'default')
        ->setComponent('google_analytics_counter', [
          'label' => 'hidden',
          'type' => 'number',
        ])
        ->save();

      // The teaser view mode is created by the Standard profile and therefore
      // might not exist.
      $view_modes = $this->entityDisplayRepository->getViewModes('node');
      if (isset($view_modes['teaser'])) {
        $this->entityDisplayRepository
          ->getViewDisplay('node', $type->id(), 'teaser')
          ->setComponent('google_analytics_counter', [
            'label' => 'hidden',
            'type' => 'textfield',
          ])
          ->save();

I'm wondering whether the field_google_analytics_counter is the correct one to add - isn't the field called field_google_analytics_counter? Or is field_google_analytics_counter referring to something else? When I look at my default and teaser display modes of a content type that I've enabled on /admin/config/system/google-analytics-counter-configure-types, I'm not seeing the google_analytics_counter listed on the view display page.

💬 Support request
Status

Active

Version

4.0

Component

Code

Created by

🇨🇦Canada brunodbo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024