@meta8/prodmetrics
v1.15.0
Published
A javascript library for interacting with ProdMetrics.
Downloads
29
Maintainers
Readme
Install ProdMetrics
In your application, install our JavaScript SDK to identify your users and display surveys.
Replace YOUR-API-KEY
with the unique API Key for your application. To find
your API Key, sign in to your ProdMetrics account and navigate to Settings >
Widget.
<!-- Install ProdMetrics SDK -->
<script type="text/javascript">
(function(n,t,a,e){var i="prodmetrics";n[i]=n[i]||function(){n[i].apiKey=e;(n[i].q=n[i].q||[]).push(arguments)};
var r=t.createElement("script");r.async=!0,r.src=a,r.onload=function(){n.ProdMetrics=n.ProdMetrics.init(e);
(n[i].q||[]).forEach(function(q){n.ProdMetrics[q[0]](q[1])});delete n[i]};
var c=t.getElementsByTagName("script")[0];c.parentNode.insertBefore(r,c)})
(window, document, "https://unpkg.com/@meta8/prodmetrics@latest/dist/index.js", "YOUR-API-KEY");
</script>
Identifying users
Use the following code in your application wherever the user is logged in, and might be shown a survey. The following code is an example; you'll need to modify it to pass in your user's data.
<!-- Identify the current user of your appliaction -->
<script>
prodmetrics('user', {
externalId: user.id,
email: user.email,
name: user.name,
firstSeenAt: new Date(user.created).toISOString()
});
</script>
Documentation
Further documentation is available at https://docs.prodmetrics.io.