Disclaimer: This is not an official Google product.
Content recommendation engines are one of key parts to increase page views in publisher's website or apps, but many publishers do not manage own content recommendation because creating a content recommendation engine yourself is hard work.
Content Recommendation using word2vec provides sample contents recommendation engine code using Google Analytics 4 data from BigQuery based on word2vec embedding.
- Google Analytics 4 data in BigQuery
- Python 3.11.4+
- Setup Python environment (e.g. pyenv etc.) with libraries based on requirements.txt.
Example
pip install requirements.txt
-
Prepare training data to use SQL for BigQuery based on sample sql (sample_extract_input_data_from_GA4.sql). In training data, each row has user_id, item_list ordered by time.
-
Prepare content data to use SQL for BigQuery based on sample sql (sample_extract_content_data_from_GA4.sql). Contents data need include contents id, contents title and contents url etc in each row.
-
Optional: adjust hyper parameter in word2vec or term of input data if you want.
-
Optional: Directory extract input and contents data from BigQuery.
- Run main.py in the root directory.
python main.py -i [Input data path] -c [Content data path] -o [Output path]
Example with sample data:
python main.py -i sample_input_data.csv -c sample_content_data.csv -o output.csv