Direct Implementation
Learn how to implement ProofIt directly in your website's code for maximum control and flexibility.
Overview
Direct implementation gives you the most control over how ProofIt is loaded and configured on your website.
Prerequisites
- A ProofIt API key
- Access to edit your website's HTML
- Basic understanding of JavaScript
API Gateway Implementation (Recommended)
Proofit now uses a secure API Gateway endpoint to deliver metrics and social proof data to your website. Each client receives a dedicated endpoint, with separate prod and beta stages for production and testing. All requests must use the GET
method and include the correct query parameters.
https://{{gateway_id}}.execute-api.eu-west-2.amazonaws.com/{{stage}}/proofit?q={{metric_queries}}&skuIds={{product_ids}}
- q: Metric query (e.g.
all
oraa_products-x-orders-1200
) - skuIds: Comma-separated product IDs (must match those cached in DynamoDB)
// Example fetch request fetch('https://abc123.execute-api.eu-west-2.amazonaws.com/prod/proofit?q=all&skuIds=PROD1234,PROD5678') .then(res => res.json()) .then(data => { // Use metrics in your UI console.log(data); });
Security: Only requests from your approved domain(s) will be accepted. Use the beta stage for testing new features or domains.
Legacy: Script-based Implementation
The previous method of installing Proofit via a direct script tag is now considered legacy. For most use cases, use the API Gateway method above. If you need to use the script directly, see the example below:
<script src="https://cdn.proofit.com/js/proofit.min.js"></script>
<script>
window.ProofIt.init({
apiKey: 'YOUR_API_KEY',
// Additional configuration options
});
</script>
Asynchronous Loading
For better performance, load ProofIt asynchronously:
<script>
(function(w,d,s,o,f,js,fjs){
w['ProofitObject']=o;w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments)};
js=d.createElement(s),fjs=d.getElementsByTagName(s)[0];
js.async=1;js.src=f;fjs.parentNode.insertBefore(js,fjs);
}(window,document,'script','proofit','https://cdn.proofit.com/js/proofit.min.js'));
proofit('init', {
apiKey: 'YOUR_API_KEY'
});
</script>
Implementation Notes
- Script Placement: Place the script as early as possible in the
<head>
section - API Key: Keep your API key secure and never expose it in client-side code
- Error Handling: Implement proper error handling for script loading failures
Advanced Configuration
Customize ProofIt's behavior with advanced configuration options:
window.ProofIt.init({
apiKey: 'YOUR_API_KEY',
analytics: {
platform: 'google-analytics',
propertyId: 'G-XXXXXXXXXX'
},
templates: {
recentPurchase: {
position: 'bottom-right',
theme: 'light'
}
},
rules: {
displayDelay: 2000,
minPurchases: 5
}
});
Troubleshooting
- Script not loading: Check your browser's console for errors
- API key issues: Verify your API key is correct and active
- Integration problems: Ensure all required configuration options are set