Appearance
Track Pageviews
The SDK automatically tracks pageviews when enablePageviews: true is set during initialization.
Automatic Tracking (Recommended)
html
<script>
AffiliateSDK.init({
apiKey: "as_XXXXYYYYZZZZ",
enablePageviews: true, // ✅ Auto-tracking enabled
});
</script>php
<?php
function heldsway_sdk() {
?>
<script>
AffiliateSDK.init({
apiKey: "<?php echo get_option('heldsway_api_key'); ?>",
enablePageviews: true // ✅ Auto-tracking enabled
});
</script>
<?php
}
add_action('wp_head', 'heldsway_sdk');
?>liquid
<script>
AffiliateSDK.init({
apiKey: "as_XXXXYYYYZZZZ",
enablePageviews: true // ✅ Auto-tracking enabled
});
</script>tsx
<Script
src="https://s3.us-east-2.amazonaws.com/cdn.rentmy.co/affiliate/affiliate-sdk.min.js"
strategy="afterInteractive"
onLoad={() => {
window.AffiliateSDK.init({
apiKey: "as_XXXXYYYYZZZZ",
enablePageviews: true, // ✅ Auto-tracking enabled
});
}}
/>typescript
export default defineNuxtPlugin(() => {
const script = document.createElement("script");
script.src =
"https://s3.us-east-2.amazonaws.com/cdn.rentmy.co/affiliate/affiliate-sdk.min.js";
script.onload = () => {
window.AffiliateSDK.init({
apiKey: "as_XXXXYYYYZZZZ",
enablePageviews: true, // ✅ Auto-tracking enabled
});
};
document.head.appendChild(script);
});Manual Tracking
Track pageviews manually when needed:
javascript
// Call manually on specific events
await AffiliateSDK.trackPageview();javascript
// Inside your custom scripts
await AffiliateSDK.trackPageview();javascript
// After dynamic content loads
await AffiliateSDK.trackPageview();tsx
// In a component
import { useEffect } from "react";
function MyComponent() {
useEffect(() => {
if (window.AffiliateSDK) {
window.AffiliateSDK.trackPageview();
}
}, []);
}typescript
// In a component
onMounted(() => {
if (window.AffiliateSDK) {
window.AffiliateSDK.trackPageview();
}
});