Last active
August 29, 2015 14:24
-
-
Save danielkhan/d63637c919add8173504 to your computer and use it in GitHub Desktop.
Adding dtagentApi to a document.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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