Marketing Integrations
Muddy integrates with multiple marketing and analytics platforms to drive conversions, track customer behavior, and enable advanced e-commerce features.
Klaviyo Email Marketing
Klaviyo provides email marketing automation, customer segmentation, and product tracking for Muddy.
Account Details
- Company ID: XTXbL5
- API Key: Stored in
wp-config.php - Lists: Newsletter, Abandoned Cart, Back in Stock, VIP Customers
Installation & Configuration
// wp-config.php
define( 'KLAVIYO_API_KEY', 'pk_xxxxxxxxxxxxx' );
define( 'KLAVIYO_COMPANY_ID', 'XTXbL5' );
Product Tracking
Track product views, add-to-cart events, and purchases for personalized recommendations.
// Track product view
document.addEventListener('DOMContentLoaded', () => {
if (document.body.classList.contains('single-bigcommerce_product')) {
const productData = {
ProductName: '<?php echo esc_js( get_the_title() ); ?>',
ProductID: '<?php echo esc_js( get_post_meta( get_the_ID(), 'bigcommerce_id', true ) ); ?>',
SKU: '<?php echo esc_js( get_post_meta( get_the_ID(), 'bigcommerce_sku', true ) ); ?>',
Categories: <?php echo json_encode( wp_get_post_terms( get_the_ID(), 'bigcommerce_category', [ 'fields' => 'names' ] ) ); ?>,
ImageURL: '<?php echo esc_js( get_the_post_thumbnail_url( get_the_ID(), 'large' ) ); ?>',
URL: '<?php echo esc_js( get_permalink() ); ?>',
Price: <?php echo esc_js( get_post_meta( get_the_ID(), 'bigcommerce_price', true ) ); ?>,
Brand: 'Muddy'
};
_learnq.push(['track', 'Viewed Product', productData]);
}
});
Add to Cart Tracking:
// Track add to cart event
document.querySelectorAll('.add-to-cart-button').forEach(button => {
button.addEventListener('click', (e) => {
const productId = e.target.dataset.productId;
const productName = e.target.dataset.productName;
const price = e.target.dataset.price;
const sku = e.target.dataset.sku;
_learnq.push(['track', 'Added to Cart', {
$value: price,
ProductName: productName,
ProductID: productId,
SKU: sku,
Categories: [],
ImageURL: '',
URL: window.location.href,
Brand: 'Muddy',
Price: price,
Quantity: 1
}]);
});
});
Customer Identification
// Identify customer on login
add_action( 'wp_login', function( $user_login, $user ) {
$customer_data = [
'$email' => $user->user_email,
'$first_name' => $user->first_name,
'$last_name' => $user->last_name,
'$phone_number' => get_user_meta( $user->ID, 'billing_phone', true ),
'CustomerID' => $user->ID
];
?>
<script>
_learnq.push(['identify', <?php echo json_encode( $customer_data ); ?>]);
</script>
<?php
}, 10, 2 );
Abandoned Cart Recovery
// Track checkout started
add_action( 'bigcommerce/checkout/redirect', function( $cart_id ) {
$cart = BigCommerce\Cart\Cart::get_cart();
$items = $cart->get_items();
$cart_data = [
'$value' => $cart->get_subtotal(),
'ItemNames' => array_map( function( $item ) {
return $item['name'];
}, $items ),
'CheckoutURL' => $cart->get_checkout_url(),
'Categories' => []
];
?>
<script>
_learnq.push(['track', 'Started Checkout', <?php echo json_encode( $cart_data ); ?>]);
</script>
<?php
} );
Post-Purchase Flow
// Track completed order
add_action( 'bigcommerce/webhooks/order/created', function( $order_id ) {
$order = get_bigcommerce_order( $order_id );
$order_data = [
'$event_id' => $order->id,
'$value' => $order->total_inc_tax,
'OrderId' => $order->id,
'Categories' => [],
'ItemNames' => array_map( function( $item ) {
return $item->name;
}, $order->products ),
'Brands' => [ 'Muddy' ],
'Items' => array_map( function( $item ) {
return [
'ProductID' => $item->product_id,
'SKU' => $item->sku,
'ProductName' => $item->name,
'Quantity' => $item->quantity,
'ItemPrice' => $item->price_inc_tax,
'RowTotal' => $item->total_inc_tax,
'ProductURL' => '',
'ImageURL' => $item->image_url,
'Categories' => []
];
}, $order->products )
];
klaviyo_track_event( $order->billing_address->email, 'Placed Order', $order_data );
} );
function klaviyo_track_event( $email, $event_name, $properties ) {
$data = [
'token' => KLAVIYO_API_KEY,
'event' => $event_name,
'customer_properties' => [
'$email' => $email
],
'properties' => $properties
];
wp_remote_post( 'https://a.klaviyo.com/api/track', [
'headers' => [ 'Content-Type' => 'application/json' ],
'body' => json_encode( $data )
] );
}
Custom Flows
Welcome Series:
- Trigger: Customer subscribes to newsletter
- Emails: Welcome (immediate), About Muddy (1 day), Product highlights (3 days)
Abandoned Cart:
- Trigger: Cart inactive for 1 hour
- Emails: Cart reminder (1 hour), Incentive (6 hours), Last chance (24 hours)
Back in Stock:
- Trigger: Product inventory > 0
- Email: Immediate notification with purchase link
Post-Purchase:
- Trigger: Order placed
- Emails: Order confirmation (immediate), Shipping update (when shipped), Product care tips (7 days), Review request (14 days)
BazaarVoice Reviews
Product ratings and reviews system integrated with the Suma BazaarVoice Integrator plugin.
Configuration
// BazaarVoice settings (wp-admin)
[
'client_name' => 'muddy',
'deployment_zone' => 'main_site',
'environment' => 'production',
'locale' => 'en_US'
]
Display Reviews on Product Page
// Single product template
add_action( 'bigcommerce/template/product/after_content', function() {
global $post;
$bc_id = get_post_meta( $post->ID, 'bigcommerce_id', true );
// BazaarVoice container
echo '<div id="BVRRContainer" data-bv-productid="' . esc_attr( $bc_id ) . '"></div>';
// Load BazaarVoice script
wp_enqueue_script(
'bazaarvoice',
'https://display.ugc.bazaarvoice.com/static/muddy/main_site/en_US/bvapi.js',
[],
null,
true
);
} );
Review Syndication
Reviews are syndicated to:
- Google Shopping (via product feed)
- Facebook Catalog
- Search engine rich snippets (schema.org)
// Add schema.org markup for reviews
add_action( 'wp_head', function() {
if ( is_singular( 'bigcommerce_product' ) ) {
$product_id = get_the_ID();
$bc_id = get_post_meta( $product_id, 'bigcommerce_id', true );
$reviews = get_bazaarvoice_reviews( $bc_id );
if ( $reviews && $reviews['TotalReviewCount'] > 0 ) {
$schema = [
'@context' => 'https://schema.org',
'@type' => 'Product',
'name' => get_the_title(),
'image' => get_the_post_thumbnail_url( $product_id, 'large' ),
'aggregateRating' => [
'@type' => 'AggregateRating',
'ratingValue' => $reviews['AverageRating'],
'reviewCount' => $reviews['TotalReviewCount']
]
];
echo '<script type="application/ld+json">' . json_encode( $schema ) . '</script>';
}
}
} );
Google Tag Manager (GTM)
Centralized tag management for analytics, conversion tracking, and marketing pixels.
Container Setup
GTM Container ID: GTM-XXXXXXX (configured in theme)
// functions.php - GTM implementation
add_action( 'wp_head', function() {
?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
<?php
}, 1 );
add_action( 'wp_body_open', function() {
?>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<?php
} );
E-Commerce Data Layer
// Push product data to dataLayer
window.dataLayer = window.dataLayer || [];
// Product detail view
dataLayer.push({
'event': 'view_item',
'ecommerce': {
'items': [{
'item_id': '<?php echo esc_js( $bc_id ); ?>',
'item_name': '<?php echo esc_js( get_the_title() ); ?>',
'item_brand': 'Muddy',
'item_category': '<?php echo esc_js( $category ); ?>',
'price': <?php echo esc_js( $price ); ?>
}]
}
});
// Add to cart
function pushAddToCart(productData) {
dataLayer.push({
'event': 'add_to_cart',
'ecommerce': {
'items': [{
'item_id': productData.id,
'item_name': productData.name,
'item_brand': 'Muddy',
'price': productData.price,
'quantity': productData.quantity
}]
}
});
}
// Purchase complete
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'transaction_id': '<?php echo esc_js( $order->id ); ?>',
'value': <?php echo esc_js( $order->total_inc_tax ); ?>,
'tax': <?php echo esc_js( $order->total_tax ); ?>,
'shipping': <?php echo esc_js( $order->shipping_cost_inc_tax ); ?>,
'currency': 'USD',
'items': [
// Order items...
]
}
});
GTM Tags Configuration
Configured Tags:
- Google Analytics 4 (GA4) Configuration
- GA4 Event - Page View
- GA4 Event - View Item
- GA4 Event - Add to Cart
- GA4 Event - Begin Checkout
- GA4 Event - Purchase
- Facebook Pixel - PageView
- Facebook Pixel - ViewContent
- Facebook Pixel - AddToCart
- Facebook Pixel - Purchase
- Google Ads Conversion Tracking
- Klaviyo Integration Events
Google Analytics 4 (GA4)
E-commerce tracking and enhanced measurement.
Property ID
GA4 Property ID: G-XXXXXXXXXX
Enhanced E-Commerce Events
All e-commerce events are tracked automatically via GTM and Suma Analytics plugin:
view_item_list- Product listing viewedselect_item- Product clickedview_item- Product detail viewedadd_to_cart- Product added to cartview_cart- Cart page viewedbegin_checkout- Checkout initiatedadd_payment_info- Payment method selectedadd_shipping_info- Shipping method selectedpurchase- Transaction completed
Custom Dimensions
// Set custom dimensions
gtag('config', 'G-XXXXXXXXXX', {
'custom_map': {
'dimension1': 'customer_type',
'dimension2': 'product_category',
'dimension3': 'dealer_locator_used'
}
});
// Track with custom dimensions
gtag('event', 'purchase', {
'customer_type': 'returning',
'product_category': 'tree-stands',
'transaction_id': 'ORDER-12345',
'value': 229.99,
'currency': 'USD'
});
Klarna Buy Now, Pay Later
Payment option for installment purchases.
Integration
Klarna is integrated at the BigCommerce checkout level.
Configuration:
- Merchant ID configured in BigCommerce admin
- Available for orders $35-$1,000
- Payment plans: 4 interest-free payments
Product Page Messaging
// Display Klarna payment options on product page
add_action( 'bigcommerce/template/product/after_price', function() {
$price = get_post_meta( get_the_ID(), 'bigcommerce_price', true );
if ( $price >= 35 && $price <= 1000 ) {
$installment = number_format( $price / 4, 2 );
?>
<div class="klarna-messaging">
<p>or 4 interest-free payments of <strong>$<?php echo $installment; ?></strong> with
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/klarna-logo.svg" alt="Klarna" style="height:20px;vertical-align:middle;">
</p>
</div>
<?php
}
} );
Sezzle Installment Payments
Alternative buy now, pay later option.
Integration
Similar to Klarna, Sezzle is integrated at checkout.
Configuration:
- Merchant ID configured in BigCommerce
- Available for orders $35+
- Payment plans: 4 payments over 6 weeks
Widget Display
// Sezzle widget on product pages
<script src="https://widget.sezzle.com/v1/javascript/price-widget?uuid=YOUR_UUID"></script>
<div class="sezzle-widget"
data-amount="<?php echo esc_attr( $price * 100 ); ?>"
data-currency="USD">
</div>
Facebook Pixel
Track customer behavior and run retargeting campaigns.
Pixel ID
Pixel ID: Configured via GTM
Events Tracked
// Page view
fbq('track', 'PageView');
// View content (product page)
fbq('track', 'ViewContent', {
content_ids: ['<?php echo esc_js( $bc_id ); ?>'],
content_type: 'product',
content_name: '<?php echo esc_js( get_the_title() ); ?>',
content_category: '<?php echo esc_js( $category ); ?>',
value: <?php echo esc_js( $price ); ?>,
currency: 'USD'
});
// Add to cart
fbq('track', 'AddToCart', {
content_ids: [productId],
content_type: 'product',
value: price,
currency: 'USD'
});
// Initiate checkout
fbq('track', 'InitiateCheckout', {
value: cartTotal,
currency: 'USD',
num_items: itemCount
});
// Purchase
fbq('track', 'Purchase', {
value: orderTotal,
currency: 'USD',
transaction_id: orderId
});
Marketing Automation Workflows
Customer Lifecycle Automation
New Visitor
│
├─> Browses Products ──> Klaviyo: Product View Tracking
│ ├─> Email: Personalized Recommendations
│ └─> Facebook: Retargeting Ad
│
├─> Adds to Cart ──> Klaviyo: Cart Tracking
│ ├─> Email: Cart Reminder (1 hour)
│ ├─> Email: Discount Offer (6 hours)
│ └─> Facebook: Dynamic Product Ad
│
├─> Completes Purchase ──> Klaviyo: Order Confirmation
│ ├─> Email: Thank You + Order Details
│ ├─> Email: Shipping Update (when shipped)
│ ├─> Email: Product Tips (7 days)
│ ├─> Email: Review Request (14 days)
│ └─> Email: Cross-sell (30 days)
│
└─> Subscribes to Newsletter ──> Klaviyo: Welcome Flow
├─> Email: Welcome (immediate)
├─> Email: Brand Story (2 days)
└─> Email: Product Highlights (5 days)
Conversion Tracking
Goal Setup (GA4)
Key Conversions:
- Purchase (primary)
- Newsletter signup
- Dealer locator usage
- Product review submission
- Account creation
Attribution Reports
Track marketing channel performance:
- Organic Search
- Paid Search (Google Ads)
- Social Media (Facebook, Instagram)
- Email Marketing (Klaviyo)
- Direct Traffic
- Referral Traffic
Privacy & Compliance
GDPR Compliance
// Cookie consent integration
add_action( 'wp_footer', function() {
?>
<script>
// Only load tracking scripts after consent
function initializeTracking() {
// GTM
// Klaviyo
// Facebook Pixel
}
// Check consent status
if (getCookie('cookie_consent') === 'accepted') {
initializeTracking();
}
</script>
<?php
} );
Data Retention
- GA4: 14 months (user-level)
- Klaviyo: Indefinite (customers can request deletion)
- BazaarVoice: Reviews retained unless requested for removal
- Server logs: 90 days