Skip to content

Instantly share code, notes, and snippets.

alewolf / gads-id-for-wc-google-listing-ads.php
Last active Aug 20, 2021
Enable product ID output for woopt Pixel Manager Google Ads dynamic remarketing for the WooCommerce Google Listing and Ads plugin
View gads-id-for-wc-google-listing-ads.php
// Place the following code into your functions.php file in your child theme
add_filter('wooptpm_product_ids', function ($product_ids, $product) {
$product_ids['gla'] = 'gla_' . $product->get_id();
return $product_ids;
}, 10, 2);
View freemius-keep-deactivate-button-enabled.js
try {
let observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "class") {
let attributeValue = jQuery(;
if (attributeValue.includes('disabled')) {
View freemius-gtm-conversion-tracking.js
// First you'll need to load the gtag.js library
function load_library(){
echo '<script async src=""></script>';
// Then output the conversion tracking scripts
// The Google Ads conversion ID must include the "AW-" in front of the number
function (response)
alewolf / wooptpm-add-custom-dimensions-event-for-ga.php
Created Aug 3, 2021
create an event for Google Analytics custom dimensions in woopt WooCommerce Pixel Manager
View wooptpm-add-custom-dimensions-event-for-ga.php
add_action('wp_head', function () {
jQuery(document).on('wooptpmAddToCart', function (event, product) {
gtag('event', 'add_to_cart', {
"send_to" :, // this is important to scope it to only GA UA and not send it to other properties
'ecomm_prodid': product.dyn_r_ids[], // you must make sure that the same ID type is being used for GA and Google Ads
alewolf / wooptpm-add-custom-dimensions-to-ga-ua.php
Last active Aug 3, 2021
add custom dimensions to Google Universal Analytics in woopt WooCommerce Pixel Manager
View wooptpm-add-custom-dimensions-to-ga-ua.php
add_filter('wooptpm_ga_ua_parameters', function ($analytics_parameters, $analytics_id){
$analytics_parameters['custom_map'] = [
'dimension1' => 'ecomm_prodid',
'dimension2' => 'ecomm_pagetype',
'dimension3' => 'ecomm_totalvalue',
return $analytics_parameters;
alewolf / wooptpm_order_items_1.php
Created Jul 21, 2021
remve an order item if it's value has been discounted to 0
View wooptpm_order_items_1.php
// The product ID must be changed and must match the specific product that you want to be removed
add_filter('wooptpm_order_items', function ($order_items, $order){
foreach($order_items as $item_id => $item ){
$product = $item->get_product();
if($product->get_id() === 14 && $item->get_total() == 0) unset($order_items[$item_id]);
View capitalize_words.js
* HubSpot custom code action
* Capitalizes the first letter of every part of a contact's first name, last name, address and city.
* Can easily be configured to update any other contact property.
* Examples:
* - john -> John
* - DOE -> Doe
View get_visitor_ip.php
protected function get_visitor_ip(): string
$proxy_headers = [
'HTTP_CF_CONNECTING_IP', // Cloudflare
'HTTP_TRUE_CLIENT_IP', // Cloudflare Enterprise
'HTTP_INCAP_CLIENT_IP', // Incapsula
View disable-wooptpm-on-thrive-editor.php
* This mu plugin deactivates the woopt Pixel Manager
* while the Thrive Theme editor is active.
* Create a file disable-wooptpm-on-thrive-editor.php.
* Place it in the /mu-plugins/ folder within the /wp-content/ folder.
* If the /mu-plugins/ folder doesn't exist yet, it must be manually created.
View changelog.php
* Keywords: freemius, readme.txt, changelog, free version, pro version
* Description: This code takes a readme.txt of a WordPress plugin, that has been prepared for deployment
* over freemius, and generates a changelog text output with the changelog for the free and one for the pro version.
$source_file = '../src/readme.txt';