Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NgxMatomo is not adding correct Matomo's script #77

Open
tushar33 opened this issue Dec 11, 2023 · 15 comments
Open

NgxMatomo is not adding correct Matomo's script #77

tushar33 opened this issue Dec 11, 2023 · 15 comments

Comments

@tushar33
Copy link

I am encountering an issue with the @ngx-matomo/tracker library (version 1.3.6) in Angular 11, where the tracking code verification fails with the error message "Tracking code verification failed. Please verify that you have installed the code correctly."

Upon inspection, I observed that the script is attempting to load from the URL https://sitename.matomo.cloud/matomo.php/matomo.js. However, attempting to access this URL results in an Internal Server Error. This discrepancy raises concerns about the accuracy of the script addition.

Notably, when inspecting the tracking code on Matomo, the provided link is formatted as //cdn.matomo.cloud/sitename.matomo.cloud/matomo.js.

I would appreciate it if you could confirm whether the script added is correct. If it is not, kindly advise on the correct method for loading the script using the URL cdn.matomo.cloud, considering the package I am currently using.

@tushar33 tushar33 changed the title NgxMatomo is not adding Matomo's script NgxMatomo is not adding correct Matomo's script Dec 11, 2023
@EmmanuelRoux
Copy link
Owner

Hi @tushar33

Can you please provide a reproduction code (or at least your configuration), so I can investigate further?

@tushar33
Copy link
Author

Service file
`import { Injectable } from '@angular/core';
import { MatomoTracker } from '@ngx-matomo/tracker';

@Injectable({
providedIn: 'root',
})
export class MatomoService {
constructor(private readonly tracker: MatomoTracker) {}

trackEvent(category: string, action: string, name?: string, value?: number): void {
// Call trackEvent method
this.tracker.trackEvent(category, action, name, value);
}
}`

app.module code
NgxMatomoTrackerModule.forRoot(environment?.matomoConfig)

I followed this doc https://github.com/EmmanuelRoux/ngx-matomo/blob/1.x/README.md

Screenshot of loading script
Desktop-screenshot

@EmmanuelRoux
Copy link
Owner

EmmanuelRoux commented Dec 11, 2023

Please add the content of the configuration (environment?.matomoConfig)

@tushar33
Copy link
Author

Configuration

matomoConfig: {
siteId: 1,
trackerUrl: 'https://sitename.matomo.cloud/matomo.php'
}

@EmmanuelRoux
Copy link
Owner

EmmanuelRoux commented Dec 11, 2023

Thanks.

As explained in the docs, the trackerUrl must be

your matomo server root url

(Section Basic setup of README)

@tushar33
Copy link
Author

tushar33 commented Dec 11, 2023

What if I want to use matomo URL as I am not setup matomo on server. Correct me if I am wrong

@EmmanuelRoux
Copy link
Owner

EmmanuelRoux commented Dec 11, 2023

I don't understand your question sorry.

How is your Matomo setup? It is necessarily deployed on some url, am I wrong?

Given the url you provided, can you try with https://sitename.matomo.cloud instead?

@tushar33
Copy link
Author

tushar33 commented Dec 11, 2023

By using this component I am expecting logs on matomo dashboard. I want to logs user clicks so I am using this component and using the configs which are available in tracking code. Following is the tracking code available

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://sitename.matomo.cloud/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src='//cdn.matomo.cloud/sitename.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

@EmmanuelRoux
Copy link
Owner

Please try using following configuration properties:

trackerUrl: 'https://sitename.matomo.cloud',
siteId: 1,
scriptUrl: '//cdn.matomo.cloud/sitename.matomo.cloud/matomo.js'

@tushar33
Copy link
Author

Thanks for help

Now script loading correctly but still Test installation is failed. Please check the screenshots
Desktop-screenshot (1)
dev-derivaz-ives-com-Web-Analytics-Reports-

@EmmanuelRoux
Copy link
Owner

Do you receive tracking data? (You can check for example if you receive realtime data)

@tushar33
Copy link
Author

Unable to check dashboard as tracking code verification failed not allowing to check data. Please suggest how to check

@EmmanuelRoux
Copy link
Owner

EmmanuelRoux commented Dec 12, 2023

Can you please try using MANUAL installation mode?

To do so:

  • include the tracking code yourself (provided by Matomo)
  • set configuration property mode: MatomoInitializationMode.MANUAL
  • remove other properties (trackerUrl, etc.)

@EmmanuelRoux
Copy link
Owner

Hi @tushar33, is your issue solved?

@tushar33
Copy link
Author

Hi @EmmanuelRoux,

not checked and kept on hold due to issue. I will check and update you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants