Skip to content

Instantly share code, notes, and snippets.

@danielkhan
Last active August 29, 2015 14:24
Show Gist options
  • Save danielkhan/d63637c919add8173504 to your computer and use it in GitHub Desktop.
Save danielkhan/d63637c919add8173504 to your computer and use it in GitHub Desktop.
Adding dtagentApi to a document.
<body>
// Your content
// [..]
// Include our ADK
<script src="/<path>/<to>/dtagentApi.js"></script>
<script>
// Use jQuery
jQuery(function ($) {
// Make sure that Dynatrace / UEM is present
if (typeof window.dT_ != 'undefined') {
// Select the author tag and fetch its value
var author = $('.single-post a[rel="author"]').text();
if (author) {
// Report it to Dynatrace
dynaTrace.reportString('author_post_pageview', author);
}
// Fetch the current Wordpress version from generator tag
var version = $('meta[name=generator]').attr("content").split(' ')[1];
if (version) {
// Report it to Dynatrace
dynaTrace.setAppVersion(version)
}
} else {
// Report in case the agent was not found
console.log("Missing dt agent");
}
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment