Support » Plugin: Pixel Caffeine » Dynamic variable

  • When we try to “ADD NEW TRACKING” or create “NEW CUSTOM AUDIENCE”, we are normally required to fill in the field with the text we want in “Pass Advanced Data” area.

    In which, in “Pass Advanced Data” area in “ADD NEW TRACKING” tab, there is no guideline on what to include in each field, or maybe I did not see it.

    Are there any way that we can use “Dynamic variable” in the field?
    such as: [category], [tags], [title], [pagetype], [price_subtotal], and so on?

    Thank you

Viewing 1 replies (of 1 total)
  • Plugin Author Antonino Scarfì



    unfortunately, there aren’t any tags already ready to use, but the plugin has a wordpress filter where define custom placeholders.

    Here an example of code snippet you can use to define some custom placeholders:

    add_filter( 'aepc_event_placeholders', function( array $placeholders ) {
    	$categories = get_the_category();
    	$tags = get_the_tags();
    	$placeholders['category'] = !is_wp_error($categories) ? implode(', ', wp_list_pluck($categories, 'name') ) : '';
    	$placeholders['tags'] = !is_wp_error($tags) ? implode(', ', wp_list_pluck($tags, 'name') ) : '';
    	$placeholders['title'] = get_the_title();
    	$placeholders['price'] = ( $product = wc_get_product() ) ? $product->get_price() : '';
    	$placeholders['price_subtotal'] = WC()->cart->get_subtotal();
    	$placeholders['pagetype'] = implode(', ', array_keys(array_filter([
    		'home' => is_front_page(),
    		'blog' => is_home(),
    		'page' => is_page(),
    		'post' => is_single(),
    		// etc ...
    	// etc...
    	return $placeholders;
    } );

    You can put this code in the functions.php file of your active theme.

    It’s a rough example, just to give the idea, but I suggest you to adapt it to your case or ask help to a developer if you haven’t the expertise to manage it.

    After that, you can use the placeholders as you have defined them inside $placeholders['<tag>'], surrounded by braces. So, as for the previous example, you can use then {{category}}, {{tags}}, and so on.

    I don’t suggest you to write this from the WordPress file editor of the theme.

    I hope it can help you.

    • This reply was modified 5 months, 1 week ago by  .
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.