", "", "", ]); } /** * Returns JavaScript snippet to track events in Matomo. * * @return string */ public static function get_event_tracker() { $code = "_paq.push(['trackEvent', 'twingle', 'donation', event.data.value.recurringRythm, event.data.value.amount]);"; return self::embed_in_base_function($code); } /** * Returns JavaScript snippet to track Matomo goals. * * @param $goal_id * The ID of your Matomo goal. * * @return string */ public static function get_goal_tracker($goal_id) { $code = "_paq.push(['trackGoal', $goal_id]);"; return self::embed_in_base_function($code); } /** * Returns JavaScript snippet to track ecommerce activity in Matomo. * * @return string */ public static function get_ecommerce_tracker() { $code = implode("\n", [ "_paq.push(['addEcommerceItem', event.data.value.rythm, '', event.data.value.target, event.data.value.amount]);", "_paq.push(['trackEcommerceOrder', 'anonymizedData', event.data.value.amount]);", ]); return self::embed_in_base_function($code); } /** * Appends the given code to the original code. * * @param $original * The original code. * @param $appendix * The code you want to append to the original code. * * @return string * The combined code after appending the appendix. */ public static function append_code($original, $appendix) { return $original . '\n' . $appendix; } }