Is there a a way to track Adobe Analytics events while using Selenium (with Python bindings)? | Community
Skip to main content
Level 2
August 25, 2023
Solved

Is there a a way to track Adobe Analytics events while using Selenium (with Python bindings)?

  • August 25, 2023
  • 2 replies
  • 2342 views

I'm creating automated tests, using Selenium and Python, and I need a way to check what events are being sent. So for instance, when a user is successfully logged in, an event is sent and I want to be able to quickly check that the event ID is correct without having to manually open the Adobe Experience Platform Debugger extension.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by mpeabody7

I solved this by using Selenium-wire. Then I have access to the requests.

 

for request in driver.requests: # Iterate through network requests query = request.querystring.replace('&', ' ') # Replace ampersand with space query = query.split() # Split on space into a list of requests for items in query: # Iterate through items in query if "events" in items: # If the word "events" is in an item items = items.replace('%3D', '=') # Replace unicode '=' with '=' items = items.replace('%2C', ' ') # Replace unicode ',' with space items = items.replace('%3A', ':') # Replace unicode ':' with ':' items = items.split() # Split on space into a list of events for e in items: # Iterate through the list of events if "events=" in e: # Strip "events=" label e = e.replace('events=', '') event_list.append(e) # Append the event to the event list

 

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
August 25, 2023

Hi,

 

I think an easy way to verify this is by examining the Adobe Datalayer object, which is populated in the Window object. This object will be filled with the events that are being triggered. You would need to collaborate with a developer or someone from analytics to confirm the event names you need to check.

 

Esteban Bustamante
mpeabody7Author
Level 2
August 25, 2023

Thanks for the reply, Esteban. I can handle confirming the event names to check, but do you know how I can access the Adobe Datalayer object with an automated test with Python?

mpeabody7AuthorAccepted solution
Level 2
December 6, 2023

I solved this by using Selenium-wire. Then I have access to the requests.

 

for request in driver.requests: # Iterate through network requests query = request.querystring.replace('&', ' ') # Replace ampersand with space query = query.split() # Split on space into a list of requests for items in query: # Iterate through items in query if "events" in items: # If the word "events" is in an item items = items.replace('%3D', '=') # Replace unicode '=' with '=' items = items.replace('%2C', ' ') # Replace unicode ',' with space items = items.replace('%3A', ':') # Replace unicode ':' with ':' items = items.split() # Split on space into a list of events for e in items: # Iterate through the list of events if "events=" in e: # Strip "events=" label e = e.replace('events=', '') event_list.append(e) # Append the event to the event list