How to track sign-ups in Analytics
This topic contains 8 replies, has 4 voices, and was last updated by Naveen Giri 4 years, 11 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: analytics, conversions, sign-ups, snippet, tracking
-
AuthorPosts
-
January 7, 2020 at 8:46 pm #524543
Hello!
We recently converted a directory site with multiple access / benefit tiers from custom in-house code to Geo. I was involved to an extent in the migration but not deeply, but I will be taking a more significant role going forward and I am working on learning Geo.
In the previous system, we tracked sign-ups for the various directory listing tiers (say, ‘Free’, ‘Basic’, ‘Premium’, etc.) with Goals in Google Analytics, and each tier had its own separate goal conversion. Now that we are using Geo / WP, the whole sign-up and upsell process is different.
Is there a relatively simple way in Geo to send an hit / event to Analytics when a new directory user (a) signs up [free], and / or (b) pays for one of the higher-tier subscriptions?
Thank you,
Michael
January 7, 2020 at 10:09 pm #524554Hello,
usually that is done on the checkout. With WP Invoicing there is the success page, and adding an event for landing on that page would do.
January 7, 2020 at 10:23 pm #524560Thank you – that may cover the paid sign-ups (assuming there is a way on the landing page to differentiate between the different sign-up tiers); does a free sign-up / submission get routed through Invoicing as well?
Michael
January 7, 2020 at 11:04 pm #524572No, I will ask the developers if they have an idea about that.
January 9, 2020 at 10:35 am #524771Hi Michael,
Do you have site running with GDv1 so i can check how it was working there? Do you have that customization code?
Le us know so can help you to achieve if easily feasible.
Regards,
KiranJanuary 9, 2020 at 4:24 pm #524873No, the site wasn’t running with GDv1 before; it was an entirely custom-code project in the past (no frameworks / no CMS) so all the form processing – and thus the tracking – was also custom.
This is the first time I am looking into sending Analytics hits for GD sign-ups / conversions at all, on any project.
January 10, 2020 at 8:48 am #524974Hello,
Try following PHP snippet to integrate Google Analytics Ecommerce Tracking with Invoicing. When customer back to the success page this will send data to Google.
/** * Google Analytics Ecommerce Tracking * * Google Analytics Ecommerce Tracking allows you to measure the number of transactions * and revenue that your website generates. * You must have added regular Google Analytics code to the top of your page and you must * also have enabled 'Ecommerce' on your Google Analytics dashboard. */ function _wpi_custom_ga_ecommerce_tracking( $invoice ) { if ( ! wpinv_is_success_page() ) { return; } $quantities_enabled = wpinv_item_quantities_enabled(); $cart_details = $invoice->get_cart_details(); $transaction = array( 'id' => $invoice->get_number(), // The transaction ID. Required. 'affiliation' => wpinv_get_business_name(), // The store or affiliation from which this transaction occurred. 'revenue' => wpinv_round_amount( $invoice->get_total() ), // Specifies the total revenue or grand total associated with the transaction. 'tax' => wpinv_use_taxes() ? wpinv_round_amount( $invoice->get_tax() ) : '0' // Specifies the total tax of the transaction. ); $items = array(); foreach ( $cart_details as $key => $cart_item ) { $item = array( 'id' => $invoice->get_number(), // Transaction ID. Required. 'name' => $cart_item['name'], // Product name. Required. 'sku' => $cart_item['id'], // Item ID/SKU/code. 'price' => isset( $cart_item['custom_price'] ) && $cart_item['custom_price'] !== '' ? wpinv_round_amount( $cart_item['custom_price'] ) : wpinv_round_amount( $cart_item['item_price'] ), // Unit price. 'currency' => $invoice->get_currency() // Local currency code. ); if ( $quantities_enabled ) { $item['quantity'] = !empty( $cart_item['quantity'] ) ? absint( $cart_item['quantity'] ) : 1; // Quantity. } $items[] = $item; } ?> <!-- Invoicing Google Analytics Ecommerce Tracking Code --> <script type="text/javascript"> _wpi_custom_ga_ecommerce_tracking_code(); function _wpi_custom_ga_ecommerce_tracking_code() { if ( typeof ga == 'undefined' ) { return; } ga('require', 'ecommerce'); ga('ecommerce:addTransaction', { <?php foreach ( $transaction as $key => $value ) { ?> '<?php echo $key; ?>': '<?php echo esc_js( $value ); ?>', <?php } ?> }); <?php foreach ( $items as $item ) { ?> ga('ecommerce:addItem', { <?php foreach ( $item as $key => $value ) { ?> '<?php echo $key; ?>': '<?php echo esc_js( $value ); ?>', <?php } ?> }); <?php } ?> ga('ecommerce:send'); } </script> <?php } add_action( 'wpinv_after_receipt', '_wpi_custom_ga_ecommerce_tracking', 10, 1 );
Regards,
KiranJanuary 13, 2020 at 6:06 pm #525417Hello again and thank you –
That snippet may get us where we would like to go with paid signups; will it also track those who sign up for free listings? That was part of my original question, and I didn’t know whether free listing sign-ups would even go through invoicing at all.
Michael
January 14, 2020 at 9:53 am #525505Hi seoadvantage,
Free listing submission will not go for invoicing. so you will need the below filter for free listing.
function _wpi_custom_ga_freeuser_tracking( $post_ID, $post_after, $post_before ) { global $post; $post_type = get_post_type( $post_ID ); $package_id = geodir_get_post_package_id( $post, $post_type ); if ( $post_type != '' && in_array( $post_type, geodir_get_posttypes() ) && 1 === $package_id ) { if ( ! empty( $post_after->post_status ) && $post_after->post_status == 'publish' && ! empty( $post_before->post_status ) && $post_before->post_status != 'publish' && $post_before->post_status != 'trash' ) { $gd_post = geodir_get_post_info( $post_ID ); if ( empty( $gd_post ) ) { return; } // do the analytic stuff here. } } } add_action( 'post_updated', '_wpi_custom_ga_freeuser_tracking', 16, 3 );
Thanks
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket