Quantcast
Channel: Matomo forums - Latest topics
Viewing all articles
Browse latest Browse all 13973

SharePoint 2013 UserId using JavaScript

$
0
0

@mrrcg wrote:

How do you get the userid using JavaScript in SharePoint 2013?

I am using/testing your FREE Piwik self-hosted application for SharePoint 2013.
I applied the JavaScript as instructed to my masterpage as instructed and I am getting data.
However, I am unable to acquire the User information (userid).

I’ve tried using “_spPageContextInfo.userId”, but on the masterpage I need to wait for the “sp.js” to load first.

I’ve tried this:

<script type="text/javascript">
  var _paq = _paq || [];

ExecuteOrDelayUntilScriptLoaded(getPageContextInfo, "sp.js");
function getPageContextInfo() {
    var userId = _spPageContextInfo.userId;
    _paq.push(['setUserId', userId]);
}

  _paq.push(['setDocumentTitle', document.title]);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
				var u="//localhost/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();

 </script>
<!-- End Piwik Code -->

Any help is appreciated.


Ryan

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 13973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>