Elevate your Conversion-Tracking using sGTM & Machine Learning | Part 3

Vertex AI is great for hosting BigQuery-developed models – especially whenever you want to do both individual and batch predictions. But sometimes all you need is a batch prediction once a day or so to enrich existing conversion data before uploading it to any advertising network. Especially since the launch of Google Ads Data Manager (I know, it is still buggy), batch predictions in BigQuery on conversion data became a viable option to create ML-based advertising algorithm feedback.

Why use BigQuery instead of Vertex-AI?

The advantages in using BigQuery for batch predictions are obvious: No extra GCP-Service, no Vertex-AI costs, less governance, no extra access-management, and so on.
That’s why you should always evaluate your requirements first before just using a new service and creating unnecessary costs.

Using BigQuery batch predictions

To do so, let’s take a look at the model, that we’ve created in the first post: ml_test.full_conversion_prediction.
For the purpose of this post, let’s assume we do have access to the GCLID (Google Ads clicks identifier) for every lead.

So this time, instead of just running the prediction, we want to add the GCLID to all the leads, that have GCLID data available. After running the prediction, we unnest the result to create a flattened table, which can be used for conversion uploads. In the result table you can now multiply the conversion value and the lead conversion probability to calculate a more accurate conversion value.

WITH predicition AS (
  SELECT
    *
  FROM
    ML.PREDICT(MODEL `ml_test.full_conversion_prediction`,
      (
      SELECT
        device_category,
        session_duration,
        # add all the required data...,
        gclid,
        conversion_value
      FROM
        `ml_test.new_data`
      WHERE
         gclid IS NOT NULL
  ))
)
# Create flattened table
SELECT
  * EXCEPT(trial_id, predicted_converted_lead_probs)
FROM
  prediction,
  UNNEST(predicted_converted_lead_probs) AS predicted_converted_lead_probs
WHERE
  predicted_converted_lead_probs.label IS TRUE

There are several resources on Google Ads Data Manager and how to use It (e.g. documentation by Google, appropriate rant by Lukas Oldenburg) so I won’t dive into that topic.

I hope this is helpful in your journey to create more sophisticated MarTech setups 🙂