Skiel
Skiel
KPCKevin Powell - Community
Created by Skiel on 10/30/2024 in #os-and-tools
UTM Tracking on Google Search
Hi everyone, hope you're doing fine. I'm trying to find a way to track with UTM when a visitor of my website comes from a search engine. For example, if I open Google.com and search 'mywebsite.com' and click the first link, I'd like to track that with a UTM with values "utm_source=google&utm_medium=search&utm_campaign=googlesearch" or something like that. I've been reading a lot the last few days regarding this and didn't find anything confirming if this is even possible, I thought about it and logically speaking I found it challenging to do with code. My questions are: Is this possible to do? In case it is, anyone knows how? I've tried with Google Analytics but they track links that already have the UTM Tracking on the URL, since 'mywebsite.com' doesn't have the UTM, I need to be able to add it when searched for (if clients looks for it on Google, source should be google, if they search on Bing, source should be bing, etc). My apologies if this isn't the right channel to post this, please let me know.
9 replies
KPCKevin Powell - Community
Created by Skiel on 7/17/2023 in #back-end
Redirect WordPress website
Hey guys, I'm kinda in a selection process and I have to do some tasks. One of them is to redirect when a checkout happens on a WooCommerce. They gave me the code that would do it and instructions. Problem is: I don't know PHP, I came with a few ways to do it but don't know if it would lead to any problem as I don't know how PHP code works. This is the code they sent me:
add_action( 'template_redirect', 'conditional_redirection_after_payment');
function conditional_redirection_after_payment(){
// When "thankyou" order-received page is reached …
if ( is_wc_endpoint_url( 'order-received' ) ) {
global $wp;

// Get the order ID from the browser url
$order_id = intval( str_replace( 'checkout/order-received/', '', $wp->request ) );

// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );

// If the order status is 'failed' we stop the function
if( $order->has_status( 'failed' ) ) return;

// HERE set in the array for each product ID the corresponding url final path
$product_id_url_paths = array(
'691' => '/card-reading',
);
// Iterating through each order items

foreach( $order->get_items() as $item_id => $item_values ){
// The Product ID

$product_id = $item_values->get_product_id();
foreach( $product_id_url_paths as $key_id => $url_path ){
if( $key_id == $product_id ){

// Product is found and ID match: we got our path url. We redirect
wp_redirect( home_url( $url_path ) );
exit(); // always exit
}
}
}
}
}
add_action( 'template_redirect', 'conditional_redirection_after_payment');
function conditional_redirection_after_payment(){
// When "thankyou" order-received page is reached …
if ( is_wc_endpoint_url( 'order-received' ) ) {
global $wp;

// Get the order ID from the browser url
$order_id = intval( str_replace( 'checkout/order-received/', '', $wp->request ) );

// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );

// If the order status is 'failed' we stop the function
if( $order->has_status( 'failed' ) ) return;

// HERE set in the array for each product ID the corresponding url final path
$product_id_url_paths = array(
'691' => '/card-reading',
);
// Iterating through each order items

foreach( $order->get_items() as $item_id => $item_values ){
// The Product ID

$product_id = $item_values->get_product_id();
foreach( $product_id_url_paths as $key_id => $url_path ){
if( $key_id == $product_id ){

// Product is found and ID match: we got our path url. We redirect
wp_redirect( home_url( $url_path ) );
exit(); // always exit
}
}
}
}
}
I already changed the product ID, I read that I have to put the requested URL to redirect in the "wp_redirect("url")" but I don't know if doing just that would lead to any problems with the rest of the code. I'm sure it will. Please help.
2 replies
KPCKevin Powell - Community
Created by Skiel on 5/17/2023 in #back-end
Resources for technical interview Javascript/NodeJs
Hey everyone! I luckily got an interview for a internship at a company. The position is for a NodeJs developer and I've been told the interview will evaluate my javascript and nodejs knowledge. Is there any resource you'd recommend so I can practice before? I'll gladly appreciate anything you can offer.
7 replies