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

Do not set ReferrerUrl on routeChangeStart #96

Open
carolineBda opened this issue Mar 27, 2023 · 3 comments
Open

Do not set ReferrerUrl on routeChangeStart #96

carolineBda opened this issue Mar 27, 2023 · 3 comments

Comments

@carolineBda
Copy link
Collaborator

carolineBda commented Mar 27, 2023

This param is used to determine how someone got to the website and not for internal navigation : https://developer.matomo.org/api-reference/tracking-api#optional-user-info

As they say here we only need to call setCustomUrl and setDocumentTitle before trackPageView

So we need to remove this bit

@maxgfr
Copy link
Member

maxgfr commented Mar 27, 2023

+1

@m-maillot
Copy link

Il parle aussi dans la section Updating the referrer un peu plus bas que l'on peut mettre à jour le referrer également. Par contre ça manque d'information de pourquoi je voudrais indiquer un referrer 🤔

@m-maillot
Copy link

D'ailleurs dans l'exemple plus loin (Measuring Single-Page Apps: Complete Example), il set un referrerUrl à la current page :

var currentUrl = location.href;
window.addEventListener('hashchange', function() {
    _paq.push(['setReferrerUrl', currentUrl]); <------------------ ICI
     currentUrl = '/' + window.location.hash.substr(1);
    _paq.push(['setCustomUrl', currentUrl]);
    _paq.push(['setDocumentTitle', 'My New Title']);

    // remove all previously assigned custom variables, requires Matomo (formerly Piwik) 3.0.2
    _paq.push(['deleteCustomVariables', 'page']);
    _paq.push(['AbTesting::create', {
       name: 'theExperimentName',
       includedTargets: [{"attribute":"url","type":"starts_with","value":"http:\/\/www.example.org","inverted":"0"}],
       excludedTargets: [],
       variations: [
          {
             name: 'original',
             activate: function (event) {
                // usually nothing needs to be done here
             }
          },
          {
             name: 'blue',
             activate: function(event) {
                // eg $('#btn').attr('style', 'color: ' + this.name + ';');
             }
          }
       ]
    }]);
    _paq.push(['trackPageView']);

    // make Matomo aware of newly added content
    var content = document.getElementById('content');
    _paq.push(['MediaAnalytics::scanForMedia', content]);
    _paq.push(['FormAnalytics::scanForForms', content]);
    _paq.push(['trackContentImpressionsWithinNode', content]);
    _paq.push(['enableLinkTracking']);
});

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

3 participants