escopecz / grav-ganalytics

Google Analytics plugin for Grav CMS
MIT License
20 stars 9 forks source link

Allow subdomains #3

Closed Edelan closed 7 years ago

Edelan commented 8 years ago

Hello,

It is possible to modify the plugin to allow configuration of multiple subdomains.

like that for example:

    trackingId:
      type: text
      size: medium
      label: Tracking ID
      placeholder: 'UA-...'
      help: Google Analytics tracking ID. In format UA-00000000-0.
    trackingSub:
      type: list
      label: Tracking subdomains
      fields:
        .url:
          type: text
          label: Subdomain URL

https://support.google.com/analytics/answer/1034342?hl=en

Regards.

Edelan commented 8 years ago

Hi again,

I am not a developer, but I found this. This works, but I don't know if it's well written.

    trackingId:
      type: text
      size: medium
      label: Tracking ID
      placeholder: 'UA-...'
      help: Google Analytics tracking ID. In format UA-00000000-0.
    trackingSub:
      type: array
      label: Subdomain url
      value_only: true

then

$trackingSub = implode("','",($this->config->get('plugins.ganalytics.trackingSub')));

and

...
    ga('create', '{$trackingId}', 'auto', {'allowLinker': true});
    ga('send', 'pageview');
    ga('require', 'linker');
    ga('linker:autoLink', ['{$trackingSub}'] );

Can you tell if this is correct.

Regards.

cworreschk commented 7 years ago

Hi @Edelan

What exactly do you want to configure? The Link you've posted is about cross domain tracking and not multiple subdomains.

cworreschk commented 7 years ago

Because of no response and the fact that tracking of subdomains can be configured in the GA backend I close this issue.