Project URL: https://www.drupal.org/project/domain_google_analytics

Google Analytics for multidomain.

Description

Add Google Analytics tracking system to your multidomain website. Please see below the steps to configure module.

1) Install/enable domain module (only domain module is required for multidomain GA module)
2) create a domain records on domain config page (http://example.com/admin/config/domain). see below screenshot
Domain Create
3) Now enable the multidomain GA module.
4) add GA code at multidomain GA config page(http://example.com/admin/config/system/multidomain-google-analytics).
5) finally you can checkout GA code at any page by using view source.

Requirements

Google Analytics account
Domain Module

Installation

1) Checkout the 8.x-1.x branch from https://git.drupal.org/project/domain_google_analytics.git
2) Enable the module and go to the configuration page http://example.com/admin/config/system/multidomain-google-analytics.
3) Add GA code for your respective domain and save.

Automated Review done for other Projects:
https://www.drupal.org/node/2870264#comment-12042921

Manual Review done for other Projects:
https://www.drupal.org/node/2871500#comment-12072301

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sushilpal created an issue. See original summary.

adrianopulz’s picture

Status: Active » Needs work

Hi @sushilpal!

Your GIT URL is wrong. I could not clone it.
Please take a look and add a Git command like this:

Project Git Url

git clone --branch 8.x-1.x https://git.drupal.org/sandbox/[your_user]/[node_ID].git

For more details about it see: https://www.drupal.org/node/1011698

sushilpal’s picture

Issue summary: View changes
sushilpal’s picture

Hi @adrianopulz,

Ohh! my apologies!

Now i have update the url at above. Also you can use http://git.drupal.org/sandbox/sushilpal/2836807.git

Thanks
S

sushilpal’s picture

Status: Needs work » Needs review
adrianopulz’s picture

Status: Needs review » Needs work
FileSize
49.67 KB

Nice!

In a first test I found some problems in coding standards and best practices. You can check it using Drupal Coder (https://www.drupal.org/project/coder). To a fast test use it: https://pareview.sh

PHPCS Test

Take a look in this test: https://pareview.sh/node/1607

deepanker_bhalla’s picture

Hi sushilpal,

Kindly see the automated review of your project as its showing some errors.

Link: https://pareview.sh/node/1607

sushilpal’s picture

Issue summary: View changes
sushilpal’s picture

Issue tags: -PAreview: review bonus
sushilpal’s picture

Hi @deepanker_bhalla, @drianopulz,

I have fixed all issue of https://pareview.sh/node/1607 except one, please take a look.

I tried but no luck. any help/idea is appreciated.

Thanks
S

adrianopulz’s picture

Hello @sushilpal!

I tried install your module to take a look in Dependency Injection problem but I received a HTTP ERROR 500 after install.

This is the error in my log:

2017/04/19 16:48:43 [error] 704#0: *126 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to a member function id() on null in /www/contrib_modules/multidomain-google-analytics/src/EventSubscriber/GoogleAnalyticResponseSubscriber.php on line 49
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /www/d8/docroot/index.php:0
PHP message: PHP   2. Drupal\Core\DrupalKernel->handle() /www/d8/docroot/index.php:19
PHP message: PHP   3. Stack\StackedHttpKernel->handle() /www/d8/docroot/core/lib/Drupal/Core/DrupalKernel.php:656
PHP message: PHP   4. Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() /www/d8/docroot/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23
PHP message: PHP   5. Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:50
PHP message: PHP   6. Drupal\page_cache\StackMiddleware\PageCache->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47
PHP message: PHP   7. Drupal\page_cache\StackMiddleware\PageCache->pass() /www/d8/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php:78
PHP message: PHP   8. Drupal\Core\StackMiddleware\KernelPreHandle->handle() /www/d8/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php:99
PHP message: PHP   9. Drupal\Core\StackMiddleware\Session->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:47
PHP message: PHP  10. Symfony\Component\HttpKernel\HttpKernel->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php:57
PHP message: PHP  11. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /www/d8/docroot/vendor/symfony/http-kernel/HttpKernel.php:64
PHP message: PHP  12. Symfony\Component\HttpKernel\HttpKernel->filterResponse() /www/d8/docroot/vendor/symfony/http-kernel/HttpKernel.php:166
PHP message: PHP  13. Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() /www/d8/docroot/vendor/symfony/http-kernel/HttpKernel.php:184
adrianopulz’s picture

@sushilpal About your Dependency Injection Warning, you will need change that implementation:

$negotiator = \Drupal::service('domain.negotiator');

For it, use your services.yml file to add the '@domain.negotiator' parameter as a argument for your class constructor. So in your GoogleAnalyticResponseSubscriber class constructor you will add this parameter like you was with the $configFactory.

So in line 48 you won't need more use $negotiator = \Drupal::service('domain.negotiator'); instead it use only some like $this->negotiator.

sushilpal’s picture

Issue summary: View changes
sushilpal’s picture

Hi drianopulz,

I install module again and did not find any error.
This module require the domain module. that's why you got the error.

Thanks
S

sushilpal’s picture

hi drianopulz,

Many thanks for your suggestion, i will try your suggestion and let you know if any issue

thanks
S

adrianopulz’s picture

FileSize
29.84 KB

Hi @sushilpal,

About the error I had the module Domain when I installed your module. I think that can be another problem.
When I installed your module only the main module (Domain) is required, so maybe you are using more.

Are you using only these? Take a look:
Domain Modules

adrianopulz’s picture

Maybe a good idea to prevent it, is do something like that:

$active_domain = $negotiator->getActiveDomain();
if ($active_domain) {
  $domainID = $active_domain->id();
  ...
}
sushilpal’s picture

Hi drianopulz,

Actually in my drupal drupal system all domain modules are enabled. that's why i am not getting error.

So now i have uninstall all domain module except domain module and working fine.

I think you need to make a entry on domain configuration page(http://example.com/admin/config/domain). please let me know if it make sense

Thanks
S

sushilpal’s picture

Status: Needs work » Needs review

Hi drianopulz,

thanks for your help, your suggestion did work :)

Now all errors (https://pareview.sh/node/1607) are removed.

Thanks
S

adrianopulz’s picture

@sushilpal,

After get your updates I uninstall your module and enable all Domain modules. When I enabled your module again I received the error below:

2017/04/19 19:38:37 [error] 703#0: *258 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to a member function id() on null in /www/d8/docroot/modules/domain/domain/src/DomainNegotiator.php on line 151
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /www/d8/docroot/index.php:0
PHP message: PHP   2. Drupal\Core\DrupalKernel->handle() /www/d8/docroot/index.php:19
PHP message: PHP   3. Stack\StackedHttpKernel->handle() /www/d8/docroot/core/lib/Drupal/Core/DrupalKernel.php:656
PHP message: PHP   4. Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() /www/d8/docroot/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23
PHP message: PHP   5. Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:50
PHP message: PHP   6. Drupal\page_cache\StackMiddleware\PageCache->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47
PHP message: PHP   7. Drupal\page_cache\StackMiddleware\PageCache->pass() /www/d8/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php:78
PHP message: PHP   8. Drupal\Core\StackMiddleware\KernelPreHandle->handle() /www/d8/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php:99
PHP message: PHP   9. Drupal\Core\StackMiddleware\Session->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:47
PHP message: PHP  10. Symfony\Component\HttpKernel\HttpKernel->handle() /www/d8/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php:57
PHP message: PHP  11. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /www/d8/docroot/vendor/symfony/http-kernel/HttpKernel.php:64
PHP message: PHP  12. Symfony\Component\HttpKernel\HttpKernel->filterResponse() /www/d8/docroot/vendor/symfony/http-kernel/HttpKernel.php:166
PHP message: PHP  13. Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() /www/d8/docroot/vendor/symfony/http-kernel/HttpKernel.php:184
PHP message: PHP  14. Drupal\Component\Dep
sushilpal’s picture

FileSize
36.16 KB

@adrianopulz,

Thanks for checking out my module.

I follow the steps mentioned by you above(uninstall/install couple of times) but i did not got any any error or notice. seems something missing.
Please see below the steps.
1) Install/enable domain module (only domain module is required for multidomain GA module)
2) create a domain records on domain config page (http://example.com/admin/config/domain). see below screenshot
Domain Create
3) Now enable the multidomain GA module.
4) add GA code at multidomain GA config page(http://example.com/admin/config/system/multidomain-google-analytics).
5) finally you can checkout GA code at any page by using view source.

Please let me know if still you find any issue.

Thanks
S

adrianopulz’s picture

Hello @sushilpal!

I tested your steps and installed the module without errors.
But normaly when someone will install your module, probably will not have the Domain module installed and configured previously.

So how your module have Domain as a requirement, Drupal will install he first and after that your module automaticaly. After that the Drupal will break and the user cant setup the domain module because all pages are with white screen.

Even if you explain in your module page to setup Domain first is not good user expirence have this error after install in case the user didn't see this rule.

A good solution is resolve it in your code, prevent this error and give to user a way to setup the Domain after install. Maybe in your module configuration page, you can add a message warning the user that he not add your domain yet. And allow the Google Analytics ID field only if exist at least one domain.

narendraR’s picture

Hi Sushil,

You can put a check in GoogleAnalyticResponseSubscriber.php constructor for active domain

    if($negotiator->getActiveDomain()){
          $this->activeDomain = $negotiator->getActiveId();
    }

You can later ask user on module configuration page to first add domain, so that they can use your module.

sushilpal’s picture

Issue summary: View changes
sushilpal’s picture

@adrianopulz,

Thanks for suggestion.

I have added steps in description and also handle error from code. Now you can check and let me know if it works for you.

Thanks
S

sushilpal’s picture

@NarendraR,

thanks for reviewing my code, i have handle the error as per as your suggestion and show the message on multidomain config page if there is no domain records added yet.

Now all seems work for me. Please let me know if any improvement.

Thanks
S

sushilpal’s picture

Issue summary: View changes
adrianopulz’s picture

Hi @sushilpal!

I tested your code again and I didn't have errors to install. At the configuration page I could see the Domain configuration missing and access directly by a link in the message. So sounds good now.

deepanker_bhalla’s picture

Hi adrianopulz,

should it be RTBC or any other error needs to be worked on?

narendraR’s picture

Status: Needs review » Reviewed & tested by the community

Hi Sushil,

Module looks good to me. Changing status to RTBC.

adrianopulz’s picture

Hello @sushilpal!

All looks good. @NarendraR changed to RTBC, thanks.

sushilpal’s picture

Issue summary: View changes
sushilpal’s picture

Issue summary: View changes
naveenvalecha’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for your valuable contribution.
Please specify how this project is different from the google analytics? Please update the issue summary with that, if this is a small feature that can get in google analytics then do that. We encourage collaboration over competition. see https://groups.drupal.org/node/184389#duplicate

There's one also another project https://www.drupal.org/project/domain_analytics Please specify how this project is different from that?

sushilpal’s picture

Thanks naveen for reply.

Actually this module is works for Multidomain site for D8. As mentioned links for GA module for D7 .

Thanks.

sushilpal’s picture

Status: Needs work » Needs review
PA robot’s picture

Status: Needs review » Needs work

Git clone failed for https://git.drupal.org/sandbox/sushilpal/2836807.git while invoking http://pareview.sh/pareview/httpsgitdrupalorgsandboxsushilpal2836807git

Git clone failed. Aborting.

I'm a robot and this is an automated message from Project Applications Scraper.

sushilpal’s picture

Issue summary: View changes
sushilpal’s picture

Status: Needs work » Needs review

Git clone URL is updated.

gaurav_manerkar’s picture

Hi @sushilpal module looks proper to me

gaurav_manerkar’s picture

Status: Needs review » Reviewed & tested by the community
sushilpal’s picture

thanks gauravmanerkar for updating status to Reviewed & tested by the community.

apaderno’s picture

Assigned: Unassigned » apaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

apaderno’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.