Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Created August 31, 2022 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimcoleman/f18c03094c3bdd7e408d16786bf8d7b1 to your computer and use it in GitHub Desktop.
Save kimcoleman/f18c03094c3bdd7e408d16786bf8d7b1 to your computer and use it in GitHub Desktop.
Add UTM tracking to footer menu use case links.
<?php
/**
* Add UTM tracking to footer menu use case links.
*/
function add_specific_menu_utm_parameters( $atts, $item, $args ) {
if ( $args->menu->slug == 'footer-menu-use-cases' ) {
$atts['href'] .= '?utm_source=footer&utm_medium=' . $atts['title'] . '&utm_campaign=use-cases';
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_specific_menu_utm_parameters', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment