Supermetrics Support Forum

Enabling Date Placeholders for Custom JSON/CSV in Data Studio

If your API supports start and end dates in the request URL, you can use the below settings to have those dynamically updated by the date selection in the report itself. There are a variety of formats to work with different requirements of the source API.


Note - if the API does not support date fields/ranges as part of the request for data, you will not be able to use these. If you are unsure if your API supports these, please consult the appropriate API documentation for what is allowed in a request call to their service.


To use the dynamic dates feature, find the place in your Source URL where the start/end dates would be defined, and instead of hardcoding the dates, add the placeholder string instead.  


Example:

Original URL

https://mywebservice.com/v1/projects/?start-date=2019-01-01&end-date=2019-02-01


Modified URL with placeholders:

https://mywebservice.com/v1/projects/?start-date=#sdate#&end-date=#edate#


The modified URL is then placed into the Source URL field of the main configuration and Data Studio then should pass the date range parameters used for the report/report object into those fields dynamically update the request.

Orange arrow points to Source URL text box now holding the modified URL with the placeholder date fields.


Do make sure the date format matches what the API web service is expecting. For example, if the date is expected to be YYYY-MM-DD, then you would use #sdate# and #edate#. Here are all the available formats for both start dates and end dates:


Date Type and format
Placeholder text to use
Start date requiring y-m-d format#sdate#
Start date requiring ymd format
#sdate_ymd#
Start date requiring unix timestamp format
#sdate_u#


End date requiring y-m-d format
#edate#
End date requiring ymd format
#edate_ymd#
End date requiring unix timestamp format
#edate_u#

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.