- Help Center
- Track Goals
- Revenue Tracking
-
General
-
Getting Started
-
Configuration
- Targeting
- Split URL
- Product Testing
- Full Stack
- Experiment Management
- CSP Configuration
- Experiment Execution
- Reports
- Exit Popups
- GTM Integration
- Troubleshooting
- Performance Optimization
- Event-Triggered Changes
- Holdout Groups
- Split URL Pages
- URL Parameters
- DataLayer
- Menu Configurations
- Traffic Exclusion
- Experiment Scheduling
- Dynamic Element Changes
- Price Targeting
- Experience Scheduling
- Privacy
- Hash Changes
- Async Tracking
- Selective Installation
- CSS Selectors
- Vue.js Integration
- Page Content
- Multipage Split URL
- Organic Traffic
- Visual Editor
- Server-Side Testing
- Traffic Bucketing
- GDPR Warnings
- Statistical Confidence
- Browser Privacy
- Query Parameters
- Embedded Videos
- Tracking Code Execution
- Simultaneous Experiments
- Tags
- Deployments
- Disable Testing
- Locations
- Programmatic Bucketting
- Query Parameter Handling
- Convert Library
- Variation Previews
- Experiment Editing
- Opt-Out Script
- Data Reset
- Body Hiding
- Visit-Specific Variations
- Variation Styling
- Preview Issues
- Variation Editing
- Full-Site Testing
- Blinking Variations
- Cross-Domain Cookies
- Regex Support
- Conversion Tracking
- SPA Testing
- Project Setup
- Cross-Domain Tracking
- Geo-Targeting
- Analytics Tools
- Campaign Tags
- Previewing
- IDs
- Query String Targeting
- Bounce Rate Goals
- Bot Filtering
- Query String Variables
- Custom Audiences
- Redirects
- Baseline
- Tracking Code Location
- Secure Cookies
- AngularJS
- Cloudflare
- Code Installation
-
Shopify
-
Track Goals
- Form Tracking
- Cookie Management
- iFrame Click Tracking
- Performance Optimization
- Revenue Tracking
- Interaction Goals
- Form Submissions
- Advanced Goals
- Lazy Loading
- Multi-Conversions
- URL Parameters
- Bounce Rate Goals
- DataLayer Integration
- Scroll Depth
- Social Interactions
- Page Views
- Marketo Forms
- Feature Analysis
- AJAX Forms
- Revenue Tracking via GTM
- Order Outliers
- Cumulative Revenue
- Goal Templates
- Adding Revenue Goals
- JS-Based Goals
- Goal Basics
- Google Analytics Goals
- Social Sharing
- Dynamic Goals
- Typeform Integration
-
Target Visitors
- Geolocation
- Interaction Goals
- Goal-Based Targeting
- Weather Targeting
- Cookie-Based Targeting
- Page Visits
- Audience Management
- Audience Segmentation
- Experiment Targeting
- Advanced Audience Creation
- Audience Templates
- Audience Creation
- Data Layer Integration
- Manual Activation
- JavaScript Conditions
- Device Targeting
- Language Targeting
- IP-Based Exclusion
- Visitor Management
- Page Tagging
- Cookies
-
Troubleshooting
- Google Warnings
- Visual Editor
- HTTPS Content
- Logs
- Support Options
- Bootstrap
- Cookie Blocking
- Change History
- Mobile Debugging
- AdWords
- Bot Exclusion
- Domain Issues
- Cloudflare Issues
- Monitoring
- Cloaking Penalties
- Goal Editor Issues
- Variations
- Snippet Performance
- Changes Not Saved
- Blocked Visual Editor
- Goal Testing
- Visual Editor Browsing
- Experiment Issues
- Installation Verification
- Data Leak Prevention
- Usage Limits
- Experiment Previews
- GA4 Revenue
- Chrome Debugger Logs
- SPA Errors
- Checkout JSON Error
-
Analyze Results
-
Integrations
- Google Analytics
- Cookie Consent Platforms
- Microsoft Clarity
- Plausible
- Marketo
- HubSpot
- Tealium
- Smartlook
- Klaviyo
- Salesforce CRM
- FullStory
- Snowplow Analytics
- Webflow
- GA4 Roles
- Amplitude
- Segment
- React
- BigCommerce
- WooCommerce
- Active Campaign
- Google Tag Manager
- Mixpanel
- Inspectlet
- Crazy Egg
- LanderApp
- Unbounce
- Instapage
- Drupal
- PrestaShop
- Magento
- Roistat
- Piano Analytics
- Heap Analytics
- Kissmetrics
- Mouseflow
- Adobe Analytics
- Clicky
-
Account Management
-
Developers
-
What's New
-
Common Questions
Scraping the Purchase Confirmation Page for Revenue Tracking
THIS ARTICLE WILL HELP YOU:
Issue Description
There are certain cases in which is not possible to track revenue through the other methods Convert provides. This may be due to, that they do not use GA, they use a custom installation of GA Ecommerce or it is not possible to refer to the revenue amount from javascript variables on the page.
Solution
So, in these cases, you could set up Convert to scrape the purchase confirmation page for the revenue after it has been rendered and then send it to Convert.
To do this you need to install some javascript code in Project Configuration > Global Javascript.
Also, you will need to go through the purchase confirmation and find the following items:
- Purchase Confirmation URL
- CSS Selector for the purchase revenue amount.
- CSS Selector for the amount of the products.
To find the CSS selectors you can look at the following article on how to find a selector of certain content.
Once you got the selectors, you can fill them in the variables of the script.
// Configuración
const CONFIG = {
purchaseConfirmURL: 'https://www.domain.com/checkout/onepage/success/',
revenueSelector: 'tr.subtotal > td.amount > .price',
productCountSelector: 'ul.items-qty > li.item > .content',
goalId: '10000001'
};
// Función principal
function initializeTracking() {
// Verifica si estamos en la página de confirmación de compra
if (!location.href.includes(CONFIG.purchaseConfirmURL)) {
console.log('No estamos en la página de confirmación de compra');
return;
}
// Verifica si Convert y jQuery están disponibles
if (typeof convert === 'undefined' || typeof convert.$ === 'undefined') {
console.error('Convert o jQuery no están disponibles');
return;
}
try {
// Obtiene los datos
const revenue = extractRevenue();
const productsCount = extractProductCount();
// Registra los datos para debugging
console.log('Datos reportados a Convert:');
console.log('Revenue:', revenue);
console.log('Products Count:', productsCount);
// Envía los datos a Convert
window._conv_q = window._conv_q || [];
window._conv_q.push(["pushRevenue", revenue, productsCount, CONFIG.goalId]);
} catch (error) {
console.error('Error al procesar los datos:', error);
}
}
// Funciones auxiliares
function extractRevenue() {
const revenueText = convert.$(CONFIG.revenueSelector).text();
return revenueText.replace(/\$/g, '').trim();
}
function extractProductCount() {
return convert.$(CONFIG.productCountSelector).text();
}
// Espera a que el documento esté listo
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeTracking);
} else {
initializeTracking();
}